Description Usage Arguments Value Author(s) Examples
predict function for kms_fit object. Places test data on same scale that the training data were by kms(). Wrapper for keras::predict_classes(). Creates a sparse model matrix with the same columns as the training data, some of which may be 0.
1 2 3 |
object |
output from kms() |
newdata |
new data. Performs merge so that X_test has the same columns as the object created by kms_fit using the user-provided input formula. y_test is also generated from that formula. |
batch_size |
To be passed to keras::predict_classes. Default == 32. |
verbose |
0 ot 1, to be passed to keras::predict_classes. Default == 0. |
... |
additional parameters to build the sparse matrix X_test. |
list containing predictions, y_test, confusion matrix.
Pete Mohanty
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | if(is_keras_available()){
mtcars$make <- unlist(lapply(strsplit(rownames(mtcars), " "), function(tokens) tokens[1]))
company <- kms(make ~ ., mtcars[3:32, ], Nepochs = 2, verbose=0)
forecast <- predict(company, mtcars[1:2, ])
forecast$confusion
# example where y_test is unavailable
trained <- kms(log(mpg) ~ ., mtcars[4:32,], Nepochs=1, verbose=0)
X_test <- subset(mtcars[1:3,], select = -mpg)
predictions <- predict(trained, X_test)
}else{
cat("Please run install_keras() before using kms(). ?install_keras for options like gpu.")
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.