JuliaAI / MLJModelInterface.jl

Lightweight package to interface with MLJ
MIT License
37 stars 8 forks source link

Problem with `fit_model_scitype` fallback for class weight support #170

Closed ablaom closed 5 months ago

ablaom commented 1 year ago

I'm getting this error when attempting to pass a class weight dictionary to the machine constructor using this model: MLJLIBSVMInterface.SVM. This is because the scitype of such a dictionary is Unknown, but fit_model_scitype is putting something else there.

ablaom commented 1 year ago
julia> mach = machine(model, X, y, weights) |> fit!
┌ Warning: The number and/or types of data arguments do not match what the specified model
│ supports. Suppress this type check by specifying `scitype_check_level=0`.
│ 
│ Run `@doc LIBSVM.ProbabilisticSVC` to learn more about your model's requirements.
│ 
│ Commonly, but non exclusively, supervised models are constructed using the syntax
│ `machine(model, X, y)` or `machine(model, X, y, w)` while most other models are
│ constructed with `machine(model, X)`.  Here `X` are features, `y` a target, and `w`
│ sample or class weights.
│ 
│ In general, data in `machine(model, data...)` is expected to satisfy
│ 
│     scitype(data) <: MLJ.fit_data_scitype(model)
│ 
│ In the present case:
│ 
│ scitype(data) = Tuple{Table{AbstractVector{Continuous}}, AbstractVector{Multiclass{3}}, Unknown}
│ 
│ fit_data_scitype(model) = Union{Tuple{Table{<:AbstractVector{<:Continuous}}, AbstractVector{<:Finite}}, Tuple{Table{<:AbstractVector{<:Continuous}}, AbstractVector{<:Finite}, AbstractDict{Finite, <:Union{Continuous, Count}}}}