Code Monkey home page Code Monkey logo

sklearn's People

Contributors

gcla avatar mattn avatar pa-m avatar sbinet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sklearn's Issues

Question: svm does not work like python.

I'm playing with pa-m/sklearn and wrote simple code to classify iris with svm.

package main

import (
	"fmt"
	"time"

	"github.com/pa-m/sklearn/datasets"
	"github.com/pa-m/sklearn/metrics"
	modelselection "github.com/pa-m/sklearn/model_selection"
	"github.com/pa-m/sklearn/preprocessing"
	"github.com/pa-m/sklearn/svm"
	"gonum.org/v1/gonum/mat"
)

func main() {
	ds := datasets.LoadIris()
	X1 := ds.X
	yscaler := preprocessing.NewMinMaxScaler([]float64{-1, 1})
	Y1, _ := yscaler.FitTransform(ds.Y, nil)
	Xtrain, Xtest, Ytrain, Ytest := modelselection.TrainTestSplit(X1, Y1, 0.25, uint64(time.Now().UnixNano()))

	clf := svm.NewSVC()
	clf.C = 0.1
	clf.Kernel = "rbf"
	clf.Fit(Xtrain, Ytrain)

	_ = Xtest
	_ = Ytest
	result := mat.NewDense(Ytest.RawMatrix().Rows, 1, nil)
	clf.Predict(Xtest, result)
	fmt.Println(mat.Formatted(result))
	fmt.Printf("%.02f%%\n", metrics.AccuracyScore(result, Ytest, true, nil)*100)
}

This is based on Python code.

import sklearn.datasets
import sklearn.model_selection
import sklearn.metrics
import sklearn.svm

iris = sklearn.datasets.load_iris()
X = iris.data
y = iris.target

X_train, X_test, y_train, y_test =\
  sklearn.model_selection.train_test_split(X, y, test_size=0.25, random_state=1234)

clf = sklearn.svm.SVC(kernel='rbf', C=0.1)
clf.fit(X_train, y_train)

y_pred = clf.predict(X_test)
score = sklearn.metrics.accuracy_score(y_test, y_pred)
print(score)

Go code don't finish training. Is this something wrong?

Not support decision tree classifier?

I find DecisionTreeClassifier api every docs but can not get any api about DecisionTreeClassifier? please tell me how can I use DecisionTreeClassifier model trained by python with this lib. Thanks a lot.

how to train in python load by golang?

as the title,i want to know,how load pkl file with golang.i train model in python with sklearn,it saved as model.pkl,then how i load it in golang? pls

Question: How do I load and use a python-trained KNearestNeighbours model on go?

Golang newbie here. So, I trained a KNN on python and new project requirements need me to deploy on Golang. I saw a few of the questions here, but I can't see a way to use a pre-loaded model. I have tried using npy files and pkl files, but I can't seem to use the predict method the way I would on python. How should I proceed?

Thanks.

Getting an array value from the result

Good day! Suppose I have this code

package main

import (
    "fmt"

    "github.com/pa-m/sklearn/neighbors"
    "gonum.org/v1/gonum/mat"
)

func main() {
    X := mat.NewDense(5, 4, []float64{0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1})
    nbrs := neighbors.NewNearestNeighbors()
    nbrs.Fit(X, mat.Matrix(nil))
    distances, indices := nbrs.KNeighbors(X, 5)
    fmt.Println(distances)
    fmt.Println()
    fmt.Println(indices)
}

The result gives me this

&{{5 5 [0 1 1 1.4142135623730951 2 0 1.4142135623730951 1.7320508075688772 1.7320508075688772 2 0 1 1 1.4142135623730951 1.7320508075688772 0 1 1.4142135623730951 1.7320508075688772 1.7320508075688772 0 1 1.4142135623730951 1.4142135623730951 1.7320508075688772] 5} 5 5}

&{{5 5 [0 2 3 4 1 1 4 2 3 0 2 0 4 3 1 3 0 2 1 4 4 2 0 1 3] 5} 5 5}

I'm expecting the result to be like this

[0 1 1 1.4142135623730951 2 0 1.4142135623730951 1.7320508075688772 1.7320508075688772 2 0 1 1 1.4142135623730951 1.7320508075688772 0 1 1.4142135623730951 1.7320508075688772 1.7320508075688772 0 1 1.4142135623730951 1.4142135623730951 1.7320508075688772]

[0 2 3 4 1 1 4 2 3 0 2 0 4 3 1 3 0 2 1 4 4 2 0 1 3]

How can I get the array value from those results as a []float64? I'll appreciate the help.

============================
Update: I already solved my problem.

gonum API change: undefined optimize.Local

As of 2704973b509448cfd217eeb036d9db869c80b837 in gonum the optimize.Local function has been removed.

This cause the library to fail building

github.com/pa-m/sklearn/linear_model/Base.go:243:15: undefined: optimize.Local

constant 9223372036854775807 overflows int

Hello everyone,

I'd like to use MinMaxScaler in my RPi4.
but there is an error while installing.
Are there any ways to use it in my RPi4?
Thank you for the reply in advance.

go: downloading github.com/pa-m/sklearn v0.0.0-20200711083454-beb861ee48b1
go: downloading golang.org/x/exp v0.0.0-20191129062945-2f5052295587
go: downloading github.com/pa-m/optimize v0.0.0-20190612075243-15ee852a6d9a
go: downloading gonum.org/v1/gonum v0.6.1
go: downloading github.com/pa-m/randomkit v0.0.0-20191001073902-db4fd80633df
go: downloading golang.org/x/tools v0.0.0-20200225230052-807dcd883420
# github.com/pa-m/optimize
/home/pi/go/pkg/mod/github.com/pa-m/[email protected]/powell.go:34:16: constant 9223372036854775807 overflows int
/home/pi/go/pkg/mod/github.com/pa-m/[email protected]/powell.go:37:15: constant 9223372036854775807 overflows int
/home/pi/go/pkg/mod/github.com/pa-m/[email protected]/powell.go:40:17: constant 9223372036854775807 overflows int
/home/pi/go/pkg/mod/github.com/pa-m/[email protected]/powell.go:43:14: constant 9223372036854775807 overflows int

Is it possible to port sklearn python pipeline into go?

Thanks for this awesome project. I think a lot of existing projects using sklearn (python) are already built and tested in python environment. If there is a solution to allow data scientists to load their sklearn python models (normally they would dump to a pickle and serve in Flask) and serve in Golang, that will be very nice. Any recommendation on how to achieve this: from an existing python model -> serve in Go?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.