在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):sjwhitworth/golearn开源软件地址(OpenSource Url):https://github.com/sjwhitworth/golearn开源编程语言(OpenSource Language):Go 84.8%开源软件介绍(OpenSource Introduction):GoLearnGoLearn is a 'batteries included' machine learning library for Go. Simplicity, paired with customisability, is the goal. We are in active development, and would love comments from users out in the wild. Drop us a line on Twitter. twitter: @golearn_ml InstallSee here for installation instructions. Getting StartedData are loaded in as Instances. You can then perform matrix like operations on them, and pass them to estimators. GoLearn implements the scikit-learn interface of Fit/Predict, so you can easily swap out estimators for trial and error. GoLearn also includes helper functions for data, like cross validation, and train and test splitting. package main
import (
"fmt"
"github.com/sjwhitworth/golearn/base"
"github.com/sjwhitworth/golearn/evaluation"
"github.com/sjwhitworth/golearn/knn"
)
func main() {
// Load in a dataset, with headers. Header attributes will be stored.
// Think of instances as a Data Frame structure in R or Pandas.
// You can also create instances from scratch.
rawData, err := base.ParseCSVToInstances("datasets/iris.csv", true)
if err != nil {
panic(err)
}
// Print a pleasant summary of your data.
fmt.Println(rawData)
//Initialises a new KNN classifier
cls := knn.NewKnnClassifier("euclidean", "linear", 2)
//Do a training-test split
trainData, testData := base.InstancesTrainTestSplit(rawData, 0.50)
cls.Fit(trainData)
//Calculates the Euclidean distance and returns the most popular label
predictions, err := cls.Predict(testData)
if err != nil {
panic(err)
}
// Prints precision/recall metrics
confusionMat, err := evaluation.GetConfusionMatrix(testData, predictions)
if err != nil {
panic(fmt.Sprintf("Unable to get confusion matrix: %s", err.Error()))
}
fmt.Println(evaluation.GetSummary(confusionMat))
}
ExamplesGoLearn comes with practical examples. Dive in and see what is going on. cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/knnclassifier
go run knnclassifier_iris.go cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/instances
go run instances.go cd $GOPATH/src/github.com/sjwhitworth/golearn/examples/trees
go run trees.go DocsJoin the teamPlease send me a mail at [email protected] |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论