gizai:ml/metrics
metrics of models.
import * as Metrics from "gizai:ml/metrics";Types
ClassMetrics
type ClassMetrics = { f1: f64; f1Micro: f64; precision: f64; recall: f64; accuracy: f64; mcc: f64; }The confusion metrics of PostgresML (src/metrics.rs): f1 macro, precision, recall and accuracy, f32; mcc as linfa's multiclass formula. y and yhat are labels rounded to integers.
f1:f64f1Micro:f64precision:f64recall:f64accuracy:f64mcc:f64
Functions
sum32
function sum32(v: Vec<f64>): f64The f32 sum of ndarray (linfa's): eight running sums over blocks of eight, joined pairwise, then the rest in order.
Effects: fail.
r2
function r2(y: Vec<f64>, yhat: Vec<f64>): f64R², mean absolute and mean squared error in f32, as linfa computes them for PostgresML over the flattened targets.
Effects: fail.
meanAbsoluteError
function meanAbsoluteError(y: Vec<f64>, yhat: Vec<f64>): f64The mean of the absolute differences between y and yhat.
Effects: fail.
meanSquaredError
function meanSquaredError(y: Vec<f64>, yhat: Vec<f64>): f64The mean of the squared differences between y and yhat.
Effects: fail.
classMetrics
function classMetrics(y: Vec<f64>, yhat: Vec<f64>, classes: i64): ClassMetrics throws stringThe confusion metrics of predictions YHAT for labels Y of CLASSES classes. It fails when the lengths differ.
Effects: fail.
sklearnScores
function sklearnScores(y: Vec<f64>, yhat: Vec<f64>): ClassMetrics throws stringscikit-learn's classification scores of PostgresML's sklearn_classification_metrics, in f32: f1, precision and recall of class 1 (average "binary") for at most two labels, else their mean over the labels (average "macro").
Effects: fail.
sklearnF1
function sklearnF1(y: Vec<f64>, yhat: Vec<f64>): f64 throws stringscikit-learn's f1_score with average "binary": an error for more than two labels.
Effects: fail.
sklearnRocAuc
function sklearnRocAuc(y: Vec<f64>, score: Vec<f64>): f64 throws stringscikit-learn's roc_auc_score of two classes, the larger one positive: the Mann-Whitney statistic, ties as halves.
Effects: fail.
sklearnRegression
function sklearnRegression(y: Vec<f64>, yhat: Vec<f64>): Vec<f64>scikit-learn's r2_score, mean_squared_error and mean_absolute_error, in f32: [r2, mse, mae]. A constant truth gives an r2 of 1 for an exact prediction, else 0.
Effects: fail.
rocAuc
function rocAuc(y: Vec<f64>, score: Vec<f64>): f64linfa's area under the ROC curve (PostgresML's roc_auc): the scores of 0 or more in ascending order, a point at each new score, the (tp, fp) rates of the points integrated by the trapezoid rule over tp, in f32.
Effects: fail.
logLoss
function logLoss(y: Vec<f64>, p: Vec<f64>): f64linfa's log loss: each probability clamped to [ε, 1 − ε] of f32, in f32.
Effects: fail.
silhouette
function silhouette(x: Vec<f64>, n: i64, d: i64, labels: Vec<f64>): f64 throws stringThe mean silhouette coefficient (Euclidean); 2 to n - 1 distinct labels.
Effects: fail.