Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/getMetricsPCA.R
getMetricsPCA allows to obtain performance measures from Confusion Matrix for algorithms with PCA pre-processing,it returns a data frame containing performance measures from the confusion matrix given by the caret
package when algorithms have been run with PCA pre-processing.
1 | getMetricsPCA(yhat, y, classtype, model)
|
yhat |
expression. The vector of predicted values. |
y |
expression. The class variable. |
classtype |
character or numeric. The number of levels in |
model |
expression. The model object to which output of the model has been assigned. |
Works with target variables that have two, three, four, six or eight classes. Similar to getMetrics
but used in the case where models have been run with PCA specified as an option for the preProcess
argument in the train
function of caret
.
Outputs an object with performance measures calculated from the confusion matrix given by the caret
package. A data frame is the resulting output with the first column giving the name of the performance measure, and the second column giving the corresponding value.
Khadija Aziz, Zainab Azough, Zakaria Kehel, Bancy Ngatia
confusionMatrix
,
predict.train
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | if(interactive()){
# Obtain predictions from several previously run models
dataX <- subset(data, select = -y)
pred.knn <- predict(model.knn, newdata = dataX)
pred.rf <- predict(model.rf, newdata = dataX)
# Get metrics for several algorithms
metrics.knn <- getMetricsPCA(y = data$y, yhat = pred.knn,
classtype = 2, model = model.knn)
metrics.rf <- getMetricsPCA(y = data$y, yhat = pred.rf,
classtype = 2, model = model.rf)
# Indexing for 2-class models to remove extra column with
# names of performance measures
metrics.all <- cbind(metrics.knn, metrics.rf[ , 2])
# No indexing needed for 3-, 4-, 6- or 8-class models
metrics.all <- cbind(metrics.knn, metrics.rf)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.