Skip to contents

This function computes and returns predictive quality metrics for a node (ctx_node) extracted from a context tree.

Usage

# S3 method for ctx_node
metrics(model, ...)

Arguments

model

T ctx_node object as returned by find_sequence().

...

Additional parameters for predictive metrics computation.

Value

The returned value is guaranteed to have at least three components

  • accuracy: the accuracy of the predictions

  • conf_mat: the confusion matrix of the predictions, with predicted values in rows and true values in columns

  • auc: the AUC of the predictive model

Details

Compared to metrics.vlmc(), this function focuses on a single context and assesses the quality of its predictions, disregarding observations that have other contexts. Apart from this limited scope, the function operates as metrics.vlmc().

References

David J. Hand and Robert J. Till (2001). "A Simple Generalisation of the Area Under the ROC Curve for Multiple Class Classification Problems." Machine Learning 45(2), p. 171--186. DOI: doi:10.1023/A:1010920819831 .

See also

Examples

pc <- powerconsumption[powerconsumption$week == 5, ]
dts <- cut(pc$active_power, breaks = c(0, quantile(pc$active_power, probs = c(0.25, 0.5, 0.75, 1))))
model <- vlmc(dts)
model_ctxs <- contexts(model)
metrics(model_ctxs[[4]])
#> Context [T]: (0,0.458], (0,0.458] 
#>  followed by (0,0.458] (161), (0.458,1.34] (36), (1.34,2.13] (1), (2.13,7.54] (1)
#>  Confusion matrix: 
#>                (0,0.458] (0.458,1.34] (1.34,2.13] (2.13,7.54] 
#>   (0,0.458]    30        9            0           0           
#>   (0.458,1.34] 0         0            0           0           
#>   (1.34,2.13]  0         0            0           0           
#>   (2.13,7.54]  0         0            0           0           
#>  Accuracy: 0.7692 
#>  AUC: NA