Closed kazucmpt closed 2 years ago
@kazucmpt Thanks for reporting.
It looks to me that you have mixed the README.md example code with some MLJ code?? The LIBSVM package does not have a fit!
method.
The train/prediction code on the README looks like this:
# Train SVM on half of the data using default parameters. See documentation
# of svmtrain for options
model = svmtrain(Xtrain, ytrain)
# Test model on the other half of the data.
ŷ, decision_values = svmpredict(model, Xtest);
# Compute accuracy
@printf "Accuracy: %.2f%%\n" mean(ŷ .== ytest) * 100
Are you wanting to train this model in MLJ? I could provide guidance if you want.
Thank you for your quick reply. Sorry, my initial code was wrong, however, the code still does not work. Anyway, I found a good answer to this problem. Now, the problem was solved.
https://stackoverflow.com/questions/62594396/how-should-i-train-a-svm-using-julia/70838091#70838091
@iblis17 Perhaps this should be re-opened. I haven't checked, but it seems from the thread cited in the previous comment that there is a problem (and the same thread proposes a correction).
@ablaom the code snippet @kazucmpt posted is indeed part of the README.md, see here, however the code works for me.
Thanks for the confirmation, @till-m !
Are you wanting to train this model in MLJ? I could provide guidance if you want.
It would be very useful/helpful to provide some example code to use it via MLJ, let's say on the iris dataset as an example. ta!
using MLJ
SVC = @load SVC pkg=LIBSVM # load code defining model type
model = SVC() # model instance
# split data
y, X = unpack(iris, ==(:class))
# fit data
mach = machine(model, X, y) |> fit!
# predict
julia> predict(mach, X)[1]
CategoricalArrays.CategoricalValue{String, UInt32} "Iris-setosa"
I use
julia 1.6.1
I installed LIBSVM.jl in Ubuntu as] add LIBSVM
After that, I run the following source code in README.md.
But I get the following error.