dataframe-learn-2.4.1.0: Interpretable, expression-returning machine learning for the dataframe ecosystem.
Safe HaskellNone
LanguageHaskell2010

DataFrame.Metrics

Description

Evaluation metrics for fitted models. The everyday entry point is evaluate, which applies a model's prediction expression and a truth column to a frame and folds a metric — no manual interpret/extract plumbing. Metrics are plain functions (type Metric = Vector -> Vector -> Double), so you pass mse or accuracy directly. Classification metrics handle multiclass via Average; classificationReport / regressionReport bundle the common numbers with a scikit-learn-style Show.

Synopsis

Metric type + evaluation

type Metric = Vector Double -> Vector Double -> Double Source #

A metric maps predictions and ground truth to a scalar score.

evaluate :: Metric -> Expr Double -> Expr Double -> DataFrame -> Double Source #

Evaluate a model's prediction expression against a truth column on a frame.

evaluate rmse (linearExpr model) (F.col @Double "target") df
evaluate accuracy (logisticDecisionExpr model) (F.col @Double "label") df

predictColumn :: Text -> Expr Double -> DataFrame -> DataFrame Source #

Add a model's prediction expression to a frame as a named column.

columnOf :: DataFrame -> Expr Double -> Vector Double Source #

Interpret an expression to a Double vector over a frame.

Regression metrics

mse :: Metric Source #

Mean squared error.

rmse :: Metric Source #

Root mean squared error.

mae :: Metric Source #

Mean absolute error.

r2 :: Metric Source #

Coefficient of determination R².

Classification metrics

accuracy :: Metric Source #

Fraction of exact matches.

logLoss :: Metric Source #

Binary log loss; probabilities clamped away from 0/1.

data Average Source #

Averaging strategy for multiclass precisionrecallF1.

Constructors

Binary Double

one class is positive; the rest negative

Macro

unweighted mean over classes

Micro

pool per-class counts (equals accuracy for single-label)

Weighted

support-weighted mean over classes

Instances

Instances details
Show Average Source # 
Instance details

Defined in DataFrame.Metrics

Eq Average Source # 
Instance details

Defined in DataFrame.Metrics

Methods

(==) :: Average -> Average -> Bool #

(/=) :: Average -> Average -> Bool #

precision :: Average -> Vector Double -> Vector Double -> Double Source #

Precision with the given averaging.

recall :: Average -> Vector Double -> Vector Double -> Double Source #

Recall with the given averaging.

f1 :: Average -> Vector Double -> Vector Double -> Double Source #

F1 with the given averaging.

rocAuc :: Vector Double -> Vector Double -> Double Source #

Binary ROC-AUC (Mann–Whitney). scores are predicted probabilities, truth is 0/1.

Per-class helpers (for reports)

classCounts :: Vector Double -> Vector Double -> [(Double, (Int, Int, Int, Int))] Source #

Per-class (tp, fp, fn, support) over the class set of truth ∪ preds.