Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

accuracy

Performance measures for regression and classification models


Description

cat2meas and tab2meas calculate the measures for a multiclass classification model.
pred2meas calculates the measures for a regression model.

Usage

cat2meas(yobs, ypred, measure = "accuracy", cost = rep(1, nlevels(yobs)))

tab2meas(tab, measure = "accuracy", cost = rep(1, nrow(tab)))

pred.MSE(yobs, ypred)

pred.RMSE(yobs, ypred)

pred.MAE(yobs, ypred)

pred2meas(yobs, ypred, measure = "RMSE")

Arguments

yobs

A vector of the labels, true class or observed response. Can be numeric, character, or factor.

ypred

A vector of the predicted labels, predicted class or predicted response. Can be numeric, character, or factor.

measure

Type of measure, see details section.

cost

Cost value by class (only for input factors).

tab

Confusion matrix (Contingency table: observed class by rows, predicted class by columns).

Details

  • cat2meas compute tab=table(yobs,ypred) and calls tab2meas function.

  • tab2meas function computes the following measures (see measure argument) for a binary classification model:

    • accuracy the accuracy classification score

    • recall, sensitivity,TPrate R=TP/(TP+FN)

    • precision P=TP/(TP+FP)

    • specificity,TNrate TN/(TN+FP)

    • FPrate FP/(TN+FP)

    • FNrate FN/(TP+FN)

    • Fmeasure 2/(1/R+1/P)

    • Gmean sqrt(R*TN/(TN+FP))

    • kappa the kappa index

    • cost sum(diag(tab)/rowSums(tab)*cost)/sum(cost)

  • pred2meas function computes the following measures of error, usign the measure argument, for observed and predicted vectors:

    • MSE Mean squared error, ∑ (ypred- yobs)^2 /n

    • RMSE Root mean squared error √(∑ (ypred- yobs)^2 /n )

    • MAE Mean Absolute Error, ∑ |yobs - ypred| /n

See Also

Other performance: weights4class()


fda.usc

Functional Data Analysis and Utilities for Statistical Computing

v2.0.2
GPL-2
Authors
Manuel Febrero Bande [aut], Manuel Oviedo de la Fuente [aut, cre], Pedro Galeano [ctb], Alicia Nieto [ctb], Eduardo Garcia-Portugues [ctb]
Initial release
2020-02-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.