Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KNNClassifier has no field or method optimisedEuclideanPredict #281

Open
waldirborbajr opened this issue Aug 19, 2022 · 2 comments
Open

Comments

@waldirborbajr
Copy link

Hi, I am trying to run a simple example and I'm facing the error below.

❯ go run cmd/main.go

github.com/sjwhitworth/golearn/knn

../../../go/pkg/mod/github.com/sjwhitworth/[email protected]/knn/knn.go:132:16: KNN.optimisedEuclideanPredict undefined (type *KNNClassifier has no field or method optimisedEuclideanPredict)

❯ go version
go version go1.19 linux/amd64

❯ cat go.mod
module localhost/mlpipeline

go 1.19

require github.com/sjwhitworth/golearn v0.0.0-20211014193759-a8b69c276cd8

require (
github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac // indirect
github.com/gonum/lapack v0.0.0-20181123203213-e4cdc5a0bff9 // indirect
github.com/gonum/matrix v0.0.0-20181209220409-c518dec07be9 // indirect
github.com/google/go-cmp v0.4.0 // indirect
github.com/guptarohit/asciigraph v0.5.1 // indirect
github.com/mattn/go-runewidth v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.4 // indirect
github.com/rocketlaunchr/dataframe-go v0.0.0-20201007021539-67b046771f0b // indirect
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 // indirect
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect
gonum.org/v1/gonum v0.8.1 // indirect
)

... code ...

// KNN classifier
cls := knn.NewKnnClassifier("euclidean", "linear", 2)
@guiyang882
Copy link

hi, i think you use the wrong way to use this packages. here its the simply examples.

cd ~/go/src/github.com/sjwhitworth/golearn/examples/knnclassifier
go build knnclassifier_iris.go

then you will get this

 wuming@B-Q4GZQ05P-1944  ~/go/src/github.com/sjwhitworth/golearn/examples/knnclassifier   master ±  ll
total 6184
-rwxr-xr-x  1 wuming  staff   3.0M Nov 14 21:50 knnclassifier_iris
-rw-r--r--  1 wuming  staff   923B Oct 14 15:57 knnclassifier_iris.go

then run the command

./knnclassifier_iris


Instances with 88 row(s) 1 attribute(s)
Attributes: 
*       CategoricalAttribute("Species", [Iris-setosa Iris-versicolor Iris-virginica])

Data:
        Iris-setosa 
        Iris-virginica 
        Iris-virginica 
        Iris-versicolor 
        Iris-setosa 
        Iris-virginica 
        Iris-setosa 
        Iris-versicolor 
        Iris-setosa 
        Iris-setosa 
        Iris-versicolor 
        Iris-versicolor 
        Iris-versicolor 
        Iris-setosa 
        Iris-virginica 
        Iris-setosa 
        Iris-setosa 
        Iris-setosa 
        Iris-virginica 
        Iris-versicolor 
        Iris-setosa 
        Iris-setosa 
        Iris-versicolor 
        Iris-versicolor 
        Iris-virginica 
        Iris-virginica 
        Iris-setosa 
        Iris-virginica 
        Iris-versicolor 
        Iris-virginica 
        ...
58 row(s) undisplayed
Reference Class True Positives  False Positives True Negatives  Precision       Recall  F1 Score
--------------- --------------  --------------- --------------  ---------       ------  --------
Iris-versicolor 27              1               58              0.9643          0.9310  0.9474
Iris-setosa     30              0               58              1.0000          1.0000  1.0000
Iris-virginica  28              2               57              0.9333          0.9655  0.9492
Overall accuracy: 0.9659

@etgcrog
Copy link

etgcrog commented Feb 21, 2023

I was having the same error. The library requires you to have the C compiler (cpp), I think installing it correctly you can solve this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants