SVM Errors With Grid Search

Yes, could you please let me know how to locate those files?

The path is given above:

Status `~/.julia/environments/v1.6/Manifest.toml`

Thank you @nilshg .
@ablaom I cannot attach zip files here, so I uploaded the .toml files to google drive and attaching the link here.

Thanks @Rahul. Unfortunately I am still unable to reproduce your error, even with same manifest.

For the record, here again is what is working for me:

using MLJ

SVMClassifier = @load SVMClassifier pkg=ScikitLearn
svm_model = SVMClassifier()

r_svm = range(svm_model, :C, values=[0.25, 0.5, 1])
self_tuning_svm = TunedModel(model=svm_model,
                             resampling=CV(nfolds=10),
                             repeats=5,
                             tuning=Grid(),
                             range=r_svm,
                             measure=accuracy)

X, y_svm = make_blobs();

svm = machine(self_tuning_svm, X, y_svm)
MLJ.fit!(svm)
predict(svm, selectrows(X, 1:2))
julia> versioninfo()
Julia Version 1.6.3
Commit ae8452a9e0 (2021-09-23 17:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.5.0)
  CPU: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
Environment:
  JULIA_LTS_PATH = /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia
  JULIA_PATH = /Applications/Julia-1.6.app/Contents/Resources/julia/bin/julia
  JULIA_EGLOT_PATH = /Applications/Julia-1.5.app/Contents/Resources/julia/bin/julia
  JULIA_NUM_THREADS = 5
  JULIA_NIGHTLY_PATH = /Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia

To be honest, Iā€™m stumped. The only thing I can think of is that ScikitLearn.jl is calling different python libraries which may also mean we are using different versions of the LIBSVM library written in C which both MLJ SVC interfaces are ultimately calling. Sorry, but Iā€™m not so knowledgeable about diagnosing this kind of issue. Perhaps one of these people can help: @stevengj @tkf @giordano @samuel_okon

At least you have a workaround: use the LIBSVM.jl version of the model.

2 Likes

Looking at the error message in the early comment SVM Errors With Grid Search - #15 by Rahul the error is from the type inference

ERROR: LoadError: TypeError: in CategoricalValue, in T, expected T<:Union{AbstractChar, AbstractString, Number}, got Type{Any}
Stacktrace:
   [1] argtypes_to_type
     @ ./compiler/typeutils.jl:50 [inlined]

(i.e., from here: https://github.com/JuliaLang/julia/blob/v1.6.4/base/compiler/typeutils.jl#L50)

which is invoked via Compiler.return_type in the Dict constructor

 [149] return_type(f::Any, t::Any)
     @ Core.Compiler ./compiler/typeinfer.jl:947
 [150] macro expansion
     @ ./array.jl:652 [inlined]
 [151] dict_with_eltype(DT_apply::F, kv::Base.Generator, t::Any) where F
     @ Base ./abstractdict.jl:541
 [152] Dict(kv::Any)
     @ Base ./dict.jl:129
 [153] (::MLJBase.var"#fit_and_extract_on_fold#299")(mach::Any, k::Any)
     @ MLJBase ~/.julia/packages/MLJBase/u6vLz/src/resampling.jl:1086

If someone can minimize the example to a single call Dict(kv) where kv is an appropriate collection of key-value pairs, I think it is worth filing an issue report to Julia. (cc @aviatesk @jameson)

1 Like