GitHub 火線榜

GitHub 火線榜 · 倉庫檔案

sjwhitworth/golearn

Machine Learning for Go (簡介來自倉庫自身文件。)

資料截至 October 27sjwhitworth

最好成績

#478

總榜 · Go 语言

9.4K

累計 Star

1.2K

Fork 總數

0

近 30 天在榜天數

專案狀態授權條款: MIT最近 push: January 15Open Issues(含 PR): 89

自 2026-10-25 起採集;未知 = 尚未採集到

把上榜徽章放進你的 README · sjwhitworth/golearn[![把上榜徽章放進你的 README](https://git.vaiox.xyz/api/badge/sjwhitworth/golearn.svg)](https://git.vaiox.xyz/zh-TW/repo/sjwhitworth/golearn)

Badge · 任何仓库都可以挂 —— 未上榜的仓库显示灰章,上完榜会自动点亮。

<a href="https://git.vaiox.xyz/zh-TW/repo/sjwhitworth/golearn"><img src="https://git.vaiox.xyz/api/badge/sjwhitworth/golearn.svg" alt="把上榜徽章放進你的 README" height="20"></a>

專案文件

GoLearn


GoDoc Build Status
Code Coverage

Support via Gittip

GoLearn 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

Install

See here for installation instructions.

Getting Started

Data 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))
}
Iris-virginica	28	2	  56	0.9333	0.9333  0.9333
Iris-setosa	    29	0	  59	1.0000  1.0000	1.0000
Iris-versicolor	27	2	  57	0.9310	0.9310  0.9310
Overall accuracy: 0.9545

Examples

GoLearn 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

Docs

Join the team

Please send me a mail at stephenjameswhitworth@gmail.com

當前上榜

  • 478

    總榜 · 史上最強 · Go

    9.4K 星 · 1.2K fork · 累計星星

    總榜 · Go →

近 30 天勢頭

近 30 天沒有上榜紀錄。

← 回到榜單

GitHub 火線榜往日榜Discover