Common metrics for evaluation of machine learning models.
Goals:
- Fast!
- Thread-safe
- Support for online evaluation
Classification:
Regression:
Documentation and example are available via godoc at http://godoc.org/github.com/bsm/mlmetrics
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())
}