Description Usage Arguments Value Warning Examples
Scale training and test datasets for anomaly detection
1 | customscale(DF_train, DF_test, a, b)
|
DF_train |
The unscaled training dataset used to scale the values in the test dataset. |
DF_test |
The unscaled test dataset scaled to the user defined interval [a, b]. |
a |
The minimum desired scaling value. This will be the minimum value of the scaled training dataset. The test dataset minimum may be smaller than this value. |
b |
The maximum desired scaling value. This will be the maximum value of the scaled training dataset. The test dataset maximum may be larger than this value. |
ScaleDF The DF_test dataset scaled to [a,b] as determined from the DF_train dataset
Requires that the test and training datasets have the same numeric features in the same order
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
# Select only numeric features
irisExample <- iris[ ,1:4]
# Add column to split 80% training and 20% test
splitIris <- irisExample %>%
dplyr::mutate(Cross = sample(c(1, 2),
size = nrow(irisExample),
replace = TRUE,
prob = c(0.80, 0.20)))
# Obtain training dataset
irisTrain <- splitIris[splitIris$Cross == 1, ] %>%
dplyr::select(-Cross)
# Obtain test dataset
irisTest <- splitIris[splitIris$Cross == 2, ] %>%
dplyr::select(-Cross)
# Scale irisTrain into [0, 1] (irisTrainZO)
irisTrainZO <- customscale(irisTrain, irisTrain, 0, 1)
# Scale irisTest into [0, 1] using
irisTest <- customscale(irisTrain, irisTest, 0 ,1)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.