metrics

package
v0.0.0-...-8433fb5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsolutePearson

type AbsolutePearson struct{}

AbsolutePearson measures the ROC AUC score.

func (AbsolutePearson) Apply

func (ap AbsolutePearson) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply AbsolutePearson.

func (AbsolutePearson) BiggerIsBetter

func (ap AbsolutePearson) BiggerIsBetter() bool

BiggerIsBetter method of AbsolutePearson.

func (AbsolutePearson) Classification

func (ap AbsolutePearson) Classification() bool

Classification method of AbsolutePearson.

func (AbsolutePearson) NeedsProbabilities

func (ap AbsolutePearson) NeedsProbabilities() bool

NeedsProbabilities method of AbsolutePearson.

func (AbsolutePearson) String

func (ap AbsolutePearson) String() string

String method of AbsolutePearson.

type Accuracy

type Accuracy struct{}

Accuracy measures the fraction of matches between true classes and predicted classes.

func (Accuracy) Apply

func (acc Accuracy) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply Accuracy.

func (Accuracy) BiggerIsBetter

func (acc Accuracy) BiggerIsBetter() bool

BiggerIsBetter method of Accuracy.

func (Accuracy) Classification

func (acc Accuracy) Classification() bool

Classification method of Accuracy.

func (Accuracy) NeedsProbabilities

func (acc Accuracy) NeedsProbabilities() bool

NeedsProbabilities method of Accuracy.

func (Accuracy) String

func (acc Accuracy) String() string

String method of Accuracy.

type ConfusionMatrix

type ConfusionMatrix map[float64]map[float64]float64

A ConfusionMatrix stores true positives (TP), true negatives (TN), false positives (FP) and false negatives (FN).

func MakeConfusionMatrix

func MakeConfusionMatrix(yTrue, yPred, weights []float64) (ConfusionMatrix, error)

MakeConfusionMatrix returns a ConfusionMatrix from a slice of true classes and another slice of predicted classes.

func (ConfusionMatrix) Classes

func (cm ConfusionMatrix) Classes() []float64

Classes returns a slice of classes included in a ConfusionMatrix. The result is ordered in ascending order.

func (ConfusionMatrix) FalseNegatives

func (cm ConfusionMatrix) FalseNegatives(class float64) float64

FalseNegatives returns the number of times a class was wrongly not predicted.

func (ConfusionMatrix) FalsePositives

func (cm ConfusionMatrix) FalsePositives(class float64) float64

FalsePositives returns the number of times a class was wrongly predicted.

func (ConfusionMatrix) NClasses

func (cm ConfusionMatrix) NClasses() int

NClasses returns the number of classes in a ConfusionMatrix.

func (ConfusionMatrix) String

func (cm ConfusionMatrix) String() string

String returns a string that can easily be read by a human in a terminal.

func (ConfusionMatrix) TrueNegatives

func (cm ConfusionMatrix) TrueNegatives(class float64) float64

TrueNegatives returns the number of times a class was correctly not predicted.

func (ConfusionMatrix) TruePositives

func (cm ConfusionMatrix) TruePositives(class float64) float64

TruePositives returns the number of times a class was correctly predicted.

type DiffMetric

type DiffMetric interface {
	Metric
	Gradients(yTrue, yPred []float64) ([]float64, error)
}

A DiffMetric is a Metric that can compute element-wise gradients.

type F1

type F1 struct {
	Class float64
}

F1 measures the F1-score.

func (F1) Apply

func (f1 F1) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply F1.

func (F1) BiggerIsBetter

func (f1 F1) BiggerIsBetter() bool

BiggerIsBetter method of F1.

func (F1) Classification

func (f1 F1) Classification() bool

Classification method of F1.

func (F1) NeedsProbabilities

func (f1 F1) NeedsProbabilities() bool

NeedsProbabilities method of F1.

func (F1) String

func (f1 F1) String() string

String method of F1.

type LogLoss

type LogLoss struct{}

LogLoss implementes logistic loss.

func (LogLoss) Apply

func (ll LogLoss) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply LogLoss.

func (LogLoss) BiggerIsBetter

func (ll LogLoss) BiggerIsBetter() bool

BiggerIsBetter method of LogLoss.

func (LogLoss) Classification

func (ll LogLoss) Classification() bool

Classification method of LogLoss.

func (LogLoss) Gradients

func (ll LogLoss) Gradients(yTrue, yPred []float64) ([]float64, error)

Gradients computes yPred[i] - yTrue[i].

func (LogLoss) NeedsProbabilities

func (ll LogLoss) NeedsProbabilities() bool

NeedsProbabilities method of LogLoss.

func (LogLoss) String

func (ll LogLoss) String() string

String method of LogLoss.

type MAE

type MAE struct{}

MAE measures the mean absolute error (MAE).

func (MAE) Apply

func (mae MAE) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MAE.

func (MAE) BiggerIsBetter

func (mae MAE) BiggerIsBetter() bool

BiggerIsBetter method of MAE.

func (MAE) Classification

func (mae MAE) Classification() bool

Classification method of MAE.

func (MAE) Gradients

func (mae MAE) Gradients(yTrue, yPred []float64) ([]float64, error)

Gradients computes sign(yPred[i] - yTrue[i]).

func (MAE) NeedsProbabilities

func (mae MAE) NeedsProbabilities() bool

NeedsProbabilities method of MAE.

func (MAE) String

func (mae MAE) String() string

String method of MAE.

type MSE

type MSE struct{}

MSE measures the mean squared error (MSE).

func (MSE) Apply

func (mse MSE) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MSE.

func (MSE) BiggerIsBetter

func (mse MSE) BiggerIsBetter() bool

BiggerIsBetter method of MSE.

func (MSE) Classification

func (mse MSE) Classification() bool

Classification method of MSE.

func (MSE) Gradients

func (mse MSE) Gradients(yTrue, yPred []float64) ([]float64, error)

Gradients computes 2 * (yPred[i] - yTrue[i]).

func (MSE) NeedsProbabilities

func (mse MSE) NeedsProbabilities() bool

NeedsProbabilities method of MSE.

func (MSE) String

func (mse MSE) String() string

String method of MSE.

type MacroF1

type MacroF1 struct{}

MacroF1 measures the global F1 score.

func (MacroF1) Apply

func (f1 MacroF1) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MacroF1.

func (MacroF1) BiggerIsBetter

func (f1 MacroF1) BiggerIsBetter() bool

BiggerIsBetter method of MacroF1.

func (MacroF1) Classification

func (f1 MacroF1) Classification() bool

Classification method of MacroF1.

func (MacroF1) NeedsProbabilities

func (f1 MacroF1) NeedsProbabilities() bool

NeedsProbabilities method of MacroF1.

func (MacroF1) String

func (f1 MacroF1) String() string

String method of MacroF1.

type MacroPrecision

type MacroPrecision struct{}

MacroPrecision measures the unweighted average precision across all classes. This does not take class imbalance into account.

func (MacroPrecision) Apply

func (precision MacroPrecision) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MacroPrecision.

func (MacroPrecision) BiggerIsBetter

func (precision MacroPrecision) BiggerIsBetter() bool

BiggerIsBetter method of MacroPrecision.

func (MacroPrecision) Classification

func (precision MacroPrecision) Classification() bool

Classification method of MacroPrecision.

func (MacroPrecision) NeedsProbabilities

func (precision MacroPrecision) NeedsProbabilities() bool

NeedsProbabilities method of MacroPrecision.

func (MacroPrecision) String

func (precision MacroPrecision) String() string

String method of MacroPrecision.

type MacroRecall

type MacroRecall struct{}

MacroRecall measures the unweighted average recall across all classes. This does not take class imbalance into account.

func (MacroRecall) Apply

func (recall MacroRecall) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MacroRecall.

func (MacroRecall) BiggerIsBetter

func (recall MacroRecall) BiggerIsBetter() bool

BiggerIsBetter method of MacroRecall.

func (MacroRecall) Classification

func (recall MacroRecall) Classification() bool

Classification method of MacroRecall.

func (MacroRecall) NeedsProbabilities

func (recall MacroRecall) NeedsProbabilities() bool

NeedsProbabilities method of MacroRecall.

func (MacroRecall) String

func (recall MacroRecall) String() string

String method of MacroRecall.

type Metric

type Metric interface {
	Apply(yTrue, yPred, weights []float64) (float64, error)
	Classification() bool
	BiggerIsBetter() bool
	NeedsProbabilities() bool
	String() string
}

A Metric metricuates the performance of a predictive model. yTrue, yPred, and weights should all have the same length. If weights is nil then uniform weights are used.

func ParseMetric

func ParseMetric(name string, class int) (Metric, error)

ParseMetric returns a Metric from it's String representation.

type MicroF1

type MicroF1 struct{}

MicroF1 measures the global F1 score.

func (MicroF1) Apply

func (f1 MicroF1) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MicroF1.

func (MicroF1) BiggerIsBetter

func (f1 MicroF1) BiggerIsBetter() bool

BiggerIsBetter method of MicroF1.

func (MicroF1) Classification

func (f1 MicroF1) Classification() bool

Classification method of MicroF1.

func (MicroF1) NeedsProbabilities

func (f1 MicroF1) NeedsProbabilities() bool

NeedsProbabilities method of MicroF1.

func (MicroF1) String

func (f1 MicroF1) String() string

String method of MicroF1.

type MicroPrecision

type MicroPrecision struct{}

MicroPrecision measures the global precision by using the total true positives and false positives.

func (MicroPrecision) Apply

func (precision MicroPrecision) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MicroPrecision.

func (MicroPrecision) BiggerIsBetter

func (precision MicroPrecision) BiggerIsBetter() bool

BiggerIsBetter method of MicroPrecision.

func (MicroPrecision) Classification

func (precision MicroPrecision) Classification() bool

Classification method of MicroPrecision.

func (MicroPrecision) NeedsProbabilities

func (precision MicroPrecision) NeedsProbabilities() bool

NeedsProbabilities method of MicroPrecision.

func (MicroPrecision) String

func (precision MicroPrecision) String() string

String method of MicroPrecision.

type MicroRecall

type MicroRecall struct{}

MicroRecall measures the global recall by using the total true positives and false negatives.

func (MicroRecall) Apply

func (recall MicroRecall) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply MicroRecall.

func (MicroRecall) BiggerIsBetter

func (recall MicroRecall) BiggerIsBetter() bool

BiggerIsBetter method of MicroRecall.

func (MicroRecall) Classification

func (recall MicroRecall) Classification() bool

Classification method of MicroRecall.

func (MicroRecall) NeedsProbabilities

func (recall MicroRecall) NeedsProbabilities() bool

NeedsProbabilities method of MicroRecall.

func (MicroRecall) String

func (recall MicroRecall) String() string

String method of MicroRecall.

type Negative

type Negative struct {
	Metric Metric
}

A Negative returns the negative output of a given Metric.

func (Negative) Apply

func (neg Negative) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply Negative.

func (Negative) BiggerIsBetter

func (neg Negative) BiggerIsBetter() bool

BiggerIsBetter method of Negative.

func (Negative) Classification

func (neg Negative) Classification() bool

Classification method of Negative.

func (Negative) NeedsProbabilities

func (neg Negative) NeedsProbabilities() bool

NeedsProbabilities method of Negative.

func (Negative) String

func (neg Negative) String() string

String method of Negative.

type Precision

type Precision struct {
	Class float64
}

Precision measures the fraction of times a class was correctly predicted.

func (Precision) Apply

func (precision Precision) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply Precision.

func (Precision) BiggerIsBetter

func (precision Precision) BiggerIsBetter() bool

BiggerIsBetter method of Precision.

func (Precision) Classification

func (precision Precision) Classification() bool

Classification method of Precision.

func (Precision) NeedsProbabilities

func (precision Precision) NeedsProbabilities() bool

NeedsProbabilities method of Precision.

func (Precision) String

func (precision Precision) String() string

String method of Precision.

type R2

type R2 struct{}

R2 measures the coefficient of determination.

func (R2) Apply

func (r2 R2) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply R2.

func (R2) BiggerIsBetter

func (r2 R2) BiggerIsBetter() bool

BiggerIsBetter method of R2.

func (R2) Classification

func (r2 R2) Classification() bool

Classification method of R2.

func (R2) NeedsProbabilities

func (r2 R2) NeedsProbabilities() bool

NeedsProbabilities method of R2.

func (R2) String

func (r2 R2) String() string

String method of R2.

type RMSE

type RMSE struct{}

RMSE measures the root mean squared error (RMSE).

func (RMSE) Apply

func (rmse RMSE) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply RMSE.

func (RMSE) BiggerIsBetter

func (rmse RMSE) BiggerIsBetter() bool

BiggerIsBetter method of RMSE.

func (RMSE) Classification

func (rmse RMSE) Classification() bool

Classification method of RMSE.

func (RMSE) NeedsProbabilities

func (rmse RMSE) NeedsProbabilities() bool

NeedsProbabilities method of RMSE.

func (RMSE) String

func (rmse RMSE) String() string

String method of RMSE.

type ROCAUC

type ROCAUC struct{}

ROCAUC measures the ROC AUC score.

func (ROCAUC) Apply

func (rocauc ROCAUC) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply ROCAUC.

func (ROCAUC) BiggerIsBetter

func (rocauc ROCAUC) BiggerIsBetter() bool

BiggerIsBetter method of ROCAUC.

func (ROCAUC) Classification

func (rocauc ROCAUC) Classification() bool

Classification method of ROCAUC.

func (ROCAUC) NeedsProbabilities

func (rocauc ROCAUC) NeedsProbabilities() bool

NeedsProbabilities method of ROCAUC.

func (ROCAUC) String

func (rocauc ROCAUC) String() string

String method of ROCAUC.

type Recall

type Recall struct {
	Class float64
}

Recall measures the fraction of times a true class was predicted.

func (Recall) Apply

func (recall Recall) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply Recall.

func (Recall) BiggerIsBetter

func (recall Recall) BiggerIsBetter() bool

BiggerIsBetter method of Recall.

func (Recall) Classification

func (recall Recall) Classification() bool

Classification method of Recall.

func (Recall) NeedsProbabilities

func (recall Recall) NeedsProbabilities() bool

NeedsProbabilities method of Recall.

func (Recall) String

func (recall Recall) String() string

String method of Recall.

type WeightedF1

type WeightedF1 struct{}

WeightedF1 measures the weighted average F1 score across all classes. This does take class imbalance into account.

func (WeightedF1) Apply

func (f1 WeightedF1) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply WeightedF1.

func (WeightedF1) BiggerIsBetter

func (f1 WeightedF1) BiggerIsBetter() bool

BiggerIsBetter method of WeightedF1.

func (WeightedF1) Classification

func (f1 WeightedF1) Classification() bool

Classification method of WeightedF1.

func (WeightedF1) NeedsProbabilities

func (f1 WeightedF1) NeedsProbabilities() bool

NeedsProbabilities method of WeightedF1.

func (WeightedF1) String

func (f1 WeightedF1) String() string

String method of WeightedF1.

type WeightedPrecision

type WeightedPrecision struct{}

WeightedPrecision measures the weighted average precision across all classes. This does take class imbalance into account.

func (WeightedPrecision) Apply

func (precision WeightedPrecision) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply WeightedPrecision.

func (WeightedPrecision) BiggerIsBetter

func (precision WeightedPrecision) BiggerIsBetter() bool

BiggerIsBetter method of WeightedPrecision.

func (WeightedPrecision) Classification

func (precision WeightedPrecision) Classification() bool

Classification method of WeightedPrecision.

func (WeightedPrecision) NeedsProbabilities

func (precision WeightedPrecision) NeedsProbabilities() bool

NeedsProbabilities method of WeightedPrecision.

func (WeightedPrecision) String

func (precision WeightedPrecision) String() string

String method of WeightedPrecision.

type WeightedRecall

type WeightedRecall struct{}

WeightedRecall measures the weighted average recall across all classes. This does take class imbalance into account.

func (WeightedRecall) Apply

func (recall WeightedRecall) Apply(yTrue, yPred, weights []float64) (float64, error)

Apply WeightedRecall.

func (WeightedRecall) BiggerIsBetter

func (recall WeightedRecall) BiggerIsBetter() bool

BiggerIsBetter method of WeightedRecall.

func (WeightedRecall) Classification

func (recall WeightedRecall) Classification() bool

Classification method of WeightedRecall.

func (WeightedRecall) NeedsProbabilities

func (recall WeightedRecall) NeedsProbabilities() bool

NeedsProbabilities method of WeightedRecall.

func (WeightedRecall) String

func (recall WeightedRecall) String() string

String method of WeightedRecall.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL