MakeTrainTest: Data-preprocessing and provide useful data for fitting

Description Usage Arguments Value

View source: R/MakeTrainTest.R

Description

This function can arrange the data (Move the outcome to the left), standardize the training data and test data using training data's information. You can also choose whether you transform the outcome with Box-Cox transformation or not. If you transform the outcome, it also returns mean value outcome_mean, standard deviation outcome_sd and Box-Cox transformation parameter lambda

Usage

1
2
3
4
5
6
7
8
MakeTrainTest(
  outcome_name,
  features_index,
  data_train,
  data_test,
  y_method = FALSE,
  boxcox = FALSE
)

Arguments

outcome_name

The outcome's name (Strings)

features_index

The index of columns you use as features

data_train

Training data

data_test

Test data

y_method

Decide how outcome will be standardized. y_method = "scale": scale the outcome by dividing with it's standard deviation (y / sd(y)). y_method = "center": centering the outcome (y - mean(y)). c("scale", "center"): standardize the outcome ((y - mean(y)) / sd(y)). If FALSE, nothing is applied to the outcome.

boxcox

If TRUE, return transformed outcome with Box-Cox transformation using car package.

Value

A list that has scaled data and separate data in features and outcome as matrix.

train

Standardized training data

test

Standardized test data

train_x

Drop outcome from train

train_y

outcome of training data (if y_method was specified, It'll be a transformed value).

test_x

Drop outcome from test

test_y

Outcome of test data (not changed)

outcome_mean

A value used for centering outcome (mean of outcome in training data)

outcome_sd

A value used for scaling outcome (standard deviation of outcome in test data)


SwanCygnus/predata documentation built on July 1, 2020, 12:09 a.m.