https://github.com/bsm/mlmetrics
Common metrics for evaluation of machine learning models
https://github.com/bsm/mlmetrics
classification confusion-matrix golang kappa logloss machine-learning matthews ml online-machine-learning r2 regression
Last synced: about 1 year ago
JSON representation
Common metrics for evaluation of machine learning models
- Host: GitHub
- URL: https://github.com/bsm/mlmetrics
- Owner: bsm
- License: apache-2.0
- Created: 2018-10-25T14:24:09.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2021-07-20T08:36:04.000Z (almost 5 years ago)
- Last Synced: 2025-03-22T19:02:45.010Z (about 1 year ago)
- Topics: classification, confusion-matrix, golang, kappa, logloss, machine-learning, matthews, ml, online-machine-learning, r2, regression
- Language: Go
- Size: 18.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ML metrics
[](https://godoc.org/github.com/bsm/mlmetrics)
[](https://github.com/bsm/openmetrics/actions/workflows/test.yml)
[](https://opensource.org/licenses/Apache-2.0)
Common metrics for evaluation of machine learning models.
Goals:
* Fast!
* Thread-safe
* Support for online evaluation
## Supported Metrics
Classification:
* [Accuracy](https://en.wikipedia.org/wiki/Accuracy_and_precision)
* [Confusion Matrix](https://en.wikipedia.org/wiki/Confusion_matrix)
* [F1 Score](https://en.wikipedia.org/wiki/F1_score)
* [Kappa](https://en.wikipedia.org/wiki/Cohen%27s_kappa)
* [Matthews](https://en.wikipedia.org/wiki/Matthews_correlation_coefficient)
* [LogLoss](https://en.wikipedia.org/wiki/Loss_functions_for_classification)
* [Precision](https://en.wikipedia.org/wiki/Information_retrieval#Precision)
* [Sensitivity](https://en.wikipedia.org/wiki/Sensitivity_(test))
Regression:
* [Mean Absolute Error](https://en.wikipedia.org/wiki/Mean_absolute_error)
* [Mean Squared Error](https://en.wikipedia.org/wiki/Mean_squared_error)
* [Root Mean Squared Error](https://en.wikipedia.org/wiki/Root-mean-square_deviation)
* [Mean Squared Error](https://en.wikipedia.org/wiki/Root-mean-square_deviation)
* [R²](https://en.wikipedia.org/wiki/Coefficient_of_determination)
## Documentation
Documentation and example are available via godoc at http://godoc.org/github.com/bsm/mlmetrics
## Example
```go
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())
}
```