mirror of
https://github.com/sjwhitworth/golearn.git
synced 2025-04-30 13:48:57 +08:00

* Refactors KNNClassifier to use them * csv handling moved back into base due to a circular dependency * Also adds the datasets used to test CSV handling
31 lines
780 B
Go
31 lines
780 B
Go
package base
|
|
|
|
import (
|
|
"github.com/gonum/matrix/mat64"
|
|
)
|
|
|
|
// Classifier implementations predict categorical class labels.
|
|
type Classifier interface {
|
|
// Takes a set of Instances, copies the class Attribute
|
|
// and constructs a new set of Instances of equivalent
|
|
// length with only the class Attribute and fills it in
|
|
// with predictions.
|
|
Predict(*Instances) *Instances
|
|
// Takes a set of instances and updates the Classifier's
|
|
// internal structures to enable prediction
|
|
Fit(*Instances)
|
|
// Why not make every classifier return a nice-looking string?
|
|
String() string
|
|
}
|
|
|
|
// BaseClassifier stores options common to every classifier.
|
|
type BaseClassifier struct {
|
|
TrainingData *Instances
|
|
}
|
|
|
|
type BaseRegressor struct {
|
|
Data mat64.Dense
|
|
Name string
|
|
Labels []float64
|
|
}
|