Description Usage Arguments Value Examples
View source: R/plot_train_valid_error.R
Takes in a model name, train/validation data sets, a parameter name and a vector of parameter values to try and then plots train/validation errors vs. parameter values.
1 2 3 4 5 6 7 8 9 | plot_train_valid_error(
model_name,
X_train,
y_train,
X_valid,
y_valid,
param_name,
param_vec
)
|
model_name |
a string of the machine learning model name. Only 'knn', 'decision tree', 'svm', and 'random forests' are allowed. |
X_train |
a numeric data frame of the training dataset without labels. |
y_train |
a numeric vector or factor of the training labels. |
X_valid |
a numeric data frame of the validation dataset without labels. |
y_valid |
a numeric vector or factor of the validation labels. |
param_name |
a string of the parameter name. Please choose this parameter based on the following information: 'knn': 'k', 'decision tree': 'maxdepth', 'svm': 'cost' or 'gamma', 'random forests': 'ntree'. |
param_vec |
a numeric vector of the parameter values. |
A plot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
library(RMLViz)
data(iris)
set.seed(123)
split <- caTools::sample.split(iris$Species, SplitRatio = 0.75)
training_set <- subset(iris, split == TRUE)
valid_set <- subset(iris, split == FALSE)
X_train <- training_set[, -5]
y_train <- training_set[, 5]
X_valid <- valid_set[, -5]
y_valid <- valid_set[, 5]
plot_train_valid_error('knn',
X_train, y_train,
X_valid, y_valid,
'k', seq(50))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.