hpiR (version 0.2.0)

createKFoldData: Create data for KFold error test

Description

Generic method for creating KFold testing data

Usage

createKFoldData(score_ids, full_data, pred_df)

Arguments

score_ids

Vector of row ids to be included in scoring data

full_data

Complete dataset (class `hpidata``) of this model type (rt or hed)

pred_df

Data to be used for prediction

Value

list of length 2 containing:

train

Training data.frame

score

Scoring data.frame

Further Details

Called from `calcKFoldError()``

Examples

Run this code
# NOT RUN {
 # Load Data
 data(ex_sales)

 # Create RT Data
 rt_data <- rtCreateTrans(trans_df = ex_sales,
                          prop_id = 'pinx',
                          trans_id = 'sale_id',
                          price = 'sale_price',
                          periodicity = 'monthly',
                          date = 'sale_date')
 # Create folds
 k_folds <- caret::createFolds(y = 1:nrow(rt_data),
                               k = 10,
                               list = TRUE,
                               returnTrain = FALSE)

 # Create data from folds
 kfold_data <- createKFoldData(score_ids = k_folds[[1]],
                               full_data = rt_data,
                               pred_df = rt_data)

# }

Run the code above in your browser using DataLab