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

Weights is not working #22

Closed
Thuener opened this issue Feb 17, 2019 · 0 comments
Closed

Weights is not working #22

Thuener opened this issue Feb 17, 2019 · 0 comments

Comments

@Thuener
Copy link
Contributor

Thuener commented Feb 17, 2019

The weights key on linear_train is not working.

using RDatasets, LIBLINEAR

# Load Fisher's classic iris data
iris = dataset("datasets", "iris")

# LIBSVM handles multi-class data automatically using a one-against-one strategy
labels = convert(Vector, iris[:Species])

# First dimension of input data is features; second is instances
inst = convert(Matrix, iris[:, 1:4])'

wei = unique(labels[1:2:end])
model = linear_train(labels[1:2:end], inst[:, 1:2:end]; weights=Dict(wei[1]=> 0.5, wei[2]=> 1., wei[3] => 3.), verbose=true)

output:

ERROR: MethodError: no method matching grp2idx(::Type{Int32}, ::Base.KeySet{CategoricalString{UInt8},Dict{CategoricalString{UInt8},Float64}}, ::Dict{CategoricalString{UInt8},Int32}, ::Array{CategoricalString{UInt8},1})
Closest candidates are:
  grp2idx(::Type{S<:Real}, ::AbstractArray{T,1} where T, ::Dict{T,Int32}, ::Array{T,1}) where {T, S<:Real} at /home/tas/.julia/packages/LIBLINEAR/xcSKN/src/LIBLINEAR.jl:115
Stacktrace:
 [1] indices_and_weights(::Array{CategoricalString{UInt8},1}, ::Array{Float64,2}, ::Dict{CategoricalString{UInt8},Float64}) at /home/tas/.julia/packages/LIBLINEAR/xcSKN/src/LIBLINEAR.jl:149
 [2] #linear_train#1(::Dict{CategoricalString{UInt8},Float64}, ::Int32, ::Float64, ::Float64, ::Float64, ::Ptr{Float64}, ::Float64, ::Bool, ::typeof(linear_train), ::Array{CategoricalString{UInt8},1}, ::Array{Float64,2}) at /home/tas/.julia/packages/LIBLINEAR/xcSKN/src/LIBLINEAR.jl:235
 [3] (::getfield(LIBLINEAR, Symbol("#kw##linear_train")))(::NamedTuple{(:weights, :verbose),Tuple{Dict{CategoricalString{UInt8},Float64},Bool}}, ::typeof(linear_train), ::Array{CategoricalString{UInt8},1}, ::Array{Float64,2}) at ./none:0
 [4] top-level scope at none:0

innerlee added a commit that referenced this issue Feb 19, 2019
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

1 participant