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

* Only numeric and categorical ARFF attributes are currently supported. * Only the dense version of the ARFF format is supported. * Compressed format is .tar.gz file which should allow extensibility. * Attributes stored using JSON representations. * Also offers smarter estimation of the precision of numeric Attributes. * Also adds support for writing instances to CSV
33 lines
606 B
Go
33 lines
606 B
Go
// Demonstrates decision tree classification
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"github.com/sjwhitworth/golearn/base"
|
|
)
|
|
|
|
func main() {
|
|
|
|
// Load in the iris dataset
|
|
iris, err := base.ParseCSVToInstances("../datasets/iris_headers.csv", true)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
for _, a := range iris.AllAttributes() {
|
|
var ac base.CategoricalAttribute
|
|
var af base.FloatAttribute
|
|
s, err := json.Marshal(a)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(string(s))
|
|
err = json.Unmarshal(s, &af)
|
|
fmt.Println(af.String())
|
|
err = json.Unmarshal(s, &ac)
|
|
fmt.Println(ac.String())
|
|
}
|
|
}
|