Learn R Programming

BCBCSF (version 0.0-2)

d2:fitpred: Functions for fitting models with MCMC, predicting class labels of test cases, and finding predictive probabilities with cross-validation

Description

bcbcsf_fitpred trains models with Gibbs sampling for each number of retained features. The results are saved in files. This function also makes predictions for test cases if they are provided.

bcbcsf_pred uses the posterior samples saved by bcbcsf_fitpred to predict the class labels of test cases. Prediction results are an array of predictive probabilities array_probs_pred, whose rows for test cases, columns for classes, and the 3rd dimension for different numbers of retained features.

cross_vld uses cross-validation to obtain predictive probabilities for all cases of a data set. This generic function can be used with bcbcsf_fitpred and other classifiers.

Usage

bcbcsf_fitpred (
  ## arguments specifying info of data sets
  X_tr, y_tr, nos_fsel = ncol (X_tr), 
  X_ts = NULL,  standardize = FALSE, rankf = FALSE,
  ## arguments for prediction
  burn = NULL, thin = 1, offset_sdxj = 0.5,
  ## arguments for Markov chain sampling
  no_rmc = 1000, no_imc = 5, no_mhwmux = 10,
  fit_bcbcsf_filepre = ".fitbcbcsf_", 
  ## arguments specifying priors for parameters and hyerparameters
  w0_mu = 0.05, alpha0_mu = 0.5, alpha1_mu = 3,
  w0_x  = 1.00, alpha0_x  = 0.5, alpha1_x  = 10,
  w0_nu = 0.05, alpha0_nu = 0.5, prior_psi = NULL,
  ## arguments for metropolis sampling for wmu, wx
  stepadj_mhwmux = 1, diag_mhwmux = FALSE,
  ## arguments for computing adjustment factor
  bcor = 1, cut_qf = exp (-10), cut_dpoi = exp (-10), nos_sim = 1000,
  ## whether look at progress
  monitor = TRUE)
  
bcbcsf_pred (X_ts, out_fit, burn = NULL, thin = 1, offset_sdxj = 0.5)

cross_vld (X, y, nfold = 10, folds = NULL, fitpred_func = bcbcsf_fitpred, ...)

Arguments

Value

nos_fsela vector of numbers of features retained.fitfilesa string vector of length nos_fsel, each saving file name of Markov chain fitting result for a number of retained features in nos_fsel; the fitfiles returned by cross_vld is for the training in the last fold.array_probs_predan array of predictive probabilities, whose rows for test cases, columns for classes, and the 3rd dimension for different numbers of retained features.fit_bcbcsfa list of Markov chain sampling results from the fitting with number of retained features equal to the last number in nos_fsel. Note that, the fitting results for other numbers (including the last one) of retained feature are saved in harddrive files if fit_bcbcsf_filepre isn't empty, and can be retrieved using function reload_fit_bcbcsf. Particularly, the list component of fit_bcbcsf has fsel saving the indice of features selected by F-statistic.