prediction {BPHO}R Documentation

Functions related to prediction

Description

The function predict_bpho predicts the response of test cases.

The function evaluate_prediction evaluates the performance of the prediction in terms of average minus log probabilities and error rate. The function split_cauchy draws samples from a Cauchy distribution of two variables constraint to that their sum is fixed.

Usage

predict_bpho(test_x,no_cls,mc_file,ptn_file,iter_b,forward,
             iters_pred)
evaluate_prediction(test_y,pred_result,file_eval_details=c())
split_cauchy(n,s, sigma1,sigmasum,debug=1)

Arguments

test_x Discrete features (also called inputs,covariates,independent variables, explanatory variables, predictor variables) of test data on which the predictions are based. The row is subject and the columns are inputs, which are coded with 1,2,..., with 0 reserved to represent that this input is not considered in a pattern. When the sequence prediction models are fitted, it is assumed that the first column is the state closest to the response. For example, a sequence `x1,x2,x3,x4' is saved in test_x as `x4,x3,x2,x1', for predicting the response `x5'.
test_y Discrete responses of test data, a vector with length equal to the row of test_x. Assumed to be coded with 1,2,... no_cls.
no_cls the number of possibilities (classes) of the response.
ptn_file a character string, the name of the binary file to which the compression result is saved. The method of writing to and reading from ptn_file can be found from the documentation compression.
mc_file A character string, the name of the binary file to which Markov chain is written. The method of writing to and reading from mc_file can be found from the documentation training.
iter_b, forward, iters_pred Starting from iter_b, one of every forward Markov chain samples, with the number of total samples being <= iters_pred and the maximum usable in the file mc_file, is used to make prediction.
pred_result the value returned from the function predict_bpho.
file_eval_details the details of evaluation is sent to the file file_eval_details.
n number of samples one wishes to obtain.
s sum of two Cauchy random variables.
sigma1 scale parameter for the first Cauchy random variable.
sigmasum the sum of scale parameters for two Cauchy random variables.
debug indicator whether you are debugging the C program.

Value

The function predict_bpho returns a data frame, with the first no_cls columns storing the predictive probabilities for each class, and the last column is the guess for the response by choosing the label of the class with largest predictive probability.
The function evaluate_prediction returns the following values:

eval_details a data frame. The first column is the true response, the second is the guessed value by taking the label of class with largest predictive probability, the third is indicator whether a wrong decision is make, the last column is the predictive probability at the true class.
error_rate the proportion of wrong prediction.
amll the average of minus log probabilities at true class, i.e. the average of the logarithms of the last column of eval_details.


The function split_cauchy returns a vector of n random numbers.

See Also

comp_train_pred,compression,training

Examples

## the function `predict_bpho' is demonstrated with the function
## `comp_train_pred' which calls `predict_bpho' inside.

## examples of 'evaluate_prediction' can be found from
## the documentation for comp_train_pred.

## testing the function split_cauchy
split_cauchy(100,10,1,5)


[Package BPHO version 1.2-5 Index]