View source: R/confusion_matrix.R
confusion_matrix | R Documentation |
Construct confusion matrix based on matrix form input. The confusion matrix is tipically defined with respect to some learning algorithm. The diagonal entries denote the correctly classified examples for respective class. All the nondiagonal entries denote misclassifications.
confusion_matrix(y_real, y_predicted, threshold = 0.5)
y_real |
Observed values (integers) to compare with (in matrix format for multiclass classification). |
y_predicted |
Predicte values (probabiblities by class). |
threshold |
Used in binary classification case. Defines the threshold of success in the classification output. The decision rule applied is greater or equal. |
matrix Confusion matrix.
# Assuming data is: y_real <- matrix( c( 1, 0, 0, 0, 1, 0, 0, 0, 1 ), ncol = 3, byrow = TRUE ) y_predicted <- matrix( c( 0.6, 0.1, 0.3, 0.7, 0.2, 0.1, 0.2, 0.3, 0.5 ), ncol = 3, byrow = TRUE ) # Resulting confusion matrix is: confusion_matrix(y_real, y_predicted)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.