stats

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassMetrics

type ClassMetrics struct {
	TruePos  int // The number of true positive results (correctly marked as positive)
	TrueNeg  int // The number of true negative results (correctly marked as negative)
	FalsePos int // The number of false positive results (that should have been negative)
	FalseNeg int // The number of false negative results (that should have been positive)
}

ClassMetrics provides methods to calculate Precision, Recall, F1Score, Accuracy and other metrics useful to analyze the accuracy of a classifier.

func NewMetricCounter

func NewMetricCounter() *ClassMetrics

NewMetricCounter returns a new ClassMetrics ready-to-use.

func (*ClassMetrics) Accuracy

func (c *ClassMetrics) Accuracy() mat.Float

Accuracy returns the accuracy metric, calculated as (true positive + true negative) / (TP + TN + FP + FN).

func (*ClassMetrics) ExpectedPos

func (c *ClassMetrics) ExpectedPos() int

ExpectedPos returns the sum of true positive and false negative

func (*ClassMetrics) F1Score

func (c *ClassMetrics) F1Score() mat.Float

F1Score returns the harmonic mean of precision and recall, calculated as 2 * (precision * recall / (precision + recall))

func (*ClassMetrics) IncFalseNeg

func (c *ClassMetrics) IncFalseNeg()

IncFalseNeg increments the false negative.

func (*ClassMetrics) IncFalsePos

func (c *ClassMetrics) IncFalsePos()

IncFalsePos increments the false positive.

func (*ClassMetrics) IncTrueNeg

func (c *ClassMetrics) IncTrueNeg()

IncTrueNeg increments the true negative.

func (*ClassMetrics) IncTruePos

func (c *ClassMetrics) IncTruePos()

IncTruePos increments the true positive.

func (*ClassMetrics) Precision

func (c *ClassMetrics) Precision() mat.Float

Precision returns the precision metric, calculated as true positive / (true positive + false positive).

func (*ClassMetrics) Recall

func (c *ClassMetrics) Recall() mat.Float

Recall returns the recall (true positive rate) metric, calculated as true positive / (true positive + false negative).

func (*ClassMetrics) Reset

func (c *ClassMetrics) Reset()

Reset sets all the counters to zero.

func (*ClassMetrics) Specificity

func (c *ClassMetrics) Specificity() mat.Float

Specificity returns the specificity (selectivity, true negative rate) metric, calculated as true negative / (true negative + false positive).

type MovingAvg

type MovingAvg struct {
	Mean     mat.Float
	Variance mat.Float
	Count    mat.Float // counts the added values
}

MovingAvg provides a convenient way to calculate the moving average by adding value incrementally.

func (*MovingAvg) Add

func (m *MovingAvg) Add(value mat.Float)

Add adds the value to the moving average.

Jump to

Keyboard shortcuts

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