Description Usage Arguments Details Value Examples
View source: R/standardizeFeature.R
Standardize a vector with the following transformation: (x - mean)/sd. Standardization makes the values of each feature in the data have zero-mean.
1 2 3 4 5 6 7 8 | standardizeFeature(
x,
na.replace = F,
sd.zero.bypass = F,
Mean = NULL,
SD = NULL,
Median = NULL
)
|
x |
A numeric/integer vector. |
na.replace |
Imputation by median (TRUE or 'median') or mean ('mean'). |
sd.zero.bypass |
If standard deviation is zero, return a vector of zeros. |
Mean |
User specified mean value. |
SD |
User specified standard deviation value. |
Median |
User specified median value. Only used for imputation (i.e. if na.replace = T). |
Feature scaling is done so that feature values are comparable across features.
For regularization when fitting a generalized linear model (e.g. with glmnet), feature scaling must be done to ensure that regularization penalties are applied with the same magnitude across features.
In stochastic gradient descent, feature scaling can improve the convergence speed of the algorithm.
User specified mean and SD can be useful when standardizing train/test sets, where the test set is standardized using the mean and sd from the training set. This is also a helper function for standardizeTrainTestSets().
Reurns a vector of standardized values
1 2 3 | standardizeFeature(c(1,1,3,5,7,11))
standardizeFeature(c(1,1,0,2,3,2,1,NA), na.replace = 'median')
standardizeFeature(c(1,1,1,1,1), sd.zero.replace = T)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.