Skip to content
/ mlmetrics Public

Common metrics for evaluation of machine learning models

License

Notifications You must be signed in to change notification settings

bsm/mlmetrics

Repository files navigation

ML metrics

GoDoc Test License

Common metrics for evaluation of machine learning models.

Goals:

  • Fast!
  • Thread-safe
  • Support for online evaluation

Supported Metrics

Classification:

Regression:

Documentation

Documentation and example are available via godoc at http://godoc.org/github.com/bsm/mlmetrics

Example

package main

import (
	"github.com/bsm/mlmetrics"
)

func main() {
	yTrue := []int{2, 0, 2, 2, 0, 1}
	yPred := []int{0, 0, 2, 2, 0, 2}

	mat := mlmetrics.NewConfusionMatrix()
	for i := range yTrue {
		mat.Observe(yTrue[i], yPred[i])
	}

	// print matrix
	for i := 0; i < mat.Order(); i++ {
		fmt.Println(mat.Row(i))
	}

	// print metrics
	fmt.Println()
	fmt.Printf("accuracy : %.3f\n", mat.Accuracy())
	fmt.Printf("kappa    : %.3f\n", mat.Kappa())
	fmt.Printf("matthews : %.3f\n", mat.Matthews())

}