-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Example about how to query the model after being trained using KNN ? #265
Comments
@ch-rigu Going through the code, the |
I'm also trying to solve this problem. After converting the user input to a FixedDataGrid the CategoricalAttribute is missing from the input data, when using As far as I understand it, I do not want to pass in the categorical info from my user input, I want that to be returned from the cls, err := knn.ReloadKNNClassifier("model.cls")
if err != nil {
log.Fatal(fmt.Errorf("loading model: %w", err))
}
toPredict := strings.NewReader("5.1,3.5,1.4,0.2")
rawData, err := base.ParseCSVToInstancesFromReader(toPredict, false)
if err != nil {
log.Fatal(fmt.Errorf("parse reader: %w", err))
}
fmt.Println(cls.TrainingData.AllAttributes())
fmt.Println(rawData.AllAttributes())
predictions, err := cls.Predict(rawData)
if err != nil {
log.Fatal(fmt.Errorf("predicting: %w", err))
} The output from the 2 print statements is;
Am I doing something wrong in the model? |
I had the same question. Is there a solution to the problem? |
邮件已收到,谢谢!
——赵淼
|
Hi!
Please cold you give an example about how to query this model after being trained ?
like when the testData is pased here: cls.Predict(testData)
it is possible do to something like this :
csv example:
Sepal length, Sepal width,Petal length, Petal width, Species
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
5.9,3.0,4.2,1.5,Iris-versicolor
6.0,2.2,4.0,1.0,Iris-versicolor
6.1,2.9,4.7,1.4,Iris-versicolor
input := '5.1,3.5,1.4,0.2'
predictions, err := cls.Predict(input)
if err != nil {
panic(err)
}
and print/get the species type ?
I managed to this in python but and quite lost about how to do it in Go
Cheers!
Chris.
The text was updated successfully, but these errors were encountered: