AsafManela / LassoPlot.jl

Plots regularization paths generated by Lasso.jl
Other
2 stars 2 forks source link

No method matching cross_validate_path #5

Closed jbrea closed 4 years ago

jbrea commented 4 years ago
using DataFrames, Lasso, LassoPlot
X = rand(10, 20); y = rand(10);
path = fit(LassoPath, X, y);
plot(path)

results in

┌ Warning: `setindex!(df::DataFrame, v::AbstractVector, col_ind::ColumnIndex)` is deprecated, use `begin
│     df[!, col_ind] = v
│     df
│ end` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::Symbol, ::Array{Symbol,1}, ::Int64, ::typeof(plot), ::LassoPath{LinearModel{LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:52
└ @ LassoPlot ~/.julia/packages/LassoPlot/ser8J/src/plots.jl:52
ERROR: MethodError: no method matching cross_validate_path(::LassoPath{LinearModel{LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}; gen=MLBase.Kfold([4, 8, 7, 6, 2, 3, 10, 5, 1, 9], 10, 1.0), select=:CVmin)
Closest candidates are:
  cross_validate_path(::R, ::AbstractArray{T,2}, ::V, ::S; offset, fitargs...) where {R<:RegularizationPath, S<:CVSegSelect, T<:AbstractFloat, V<:(AbstractArray{T,1} where T<:AbstractFloat)} at /home/j/.julia/packages/Lasso/zI2ts/src/cross_validation.jl:35
  cross_validate_path(::RegularizationPath, ::S; fitargs...) where S<:CVSegSelect at /home/j/.julia/packages/Lasso/zI2ts/src/cross_validation.jl:109
Stacktrace:
 [1] #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::Symbol, ::Array{Symbol,1}, ::Int64, ::typeof(plot), ::LassoPath{LinearModel{LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at /home/j/.julia/packages/LassoPlot/ser8J/src/plots.jl:72
 [2] plot(::LassoPath{LinearModel{LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at /home/j/.julia/packages/LassoPlot/ser8J/src/plots.jl:34
 [3] top-level scope at REPL[9]:1

This is in julia 1.3.0 with Lasso v0.5.0 or v0.4.0, LassoPlot v1.1.0 or v1.0.1 and DataFrames v0.20.0.

AsafManela commented 4 years ago

Are you sure you are using LassoPlot v1.1.0? It should be compatible with Lasso v0.5.0. Can you include the output of using Pkg; Pkg.status()?

jbrea commented 4 years ago

Sorry, I probably didn't restart julia when I added the new versions. I get many warnings but the plot is working.

julia> plot(path)
┌ Warning: `setindex!(df::DataFrame, v::AbstractVector, col_ind::ColumnIndex)` is deprecated, use `begin
│     df[!, col_ind] = v
│     df
│ end` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:52
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:52
┌ Warning: `setindex!(df::DataFrame, v::AbstractVector, col_ind::ColumnIndex)` is deprecated, use `begin
│     df[!, col_ind] = v
│     df
│ end` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:89
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:89
┌ Warning: `melt(df::AbstractDataFrame, id_vars; variable_name::Symbol=:variable, value_name::Symbol=:value, view::Bool=false)` is deprecated, use `stack(df, Not(id_vars); variable_name=variable_name, value_name=value_name, view=view)` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:92
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:92
┌ Warning: `melt(df::AbstractDataFrame, id_vars; variable_name::Symbol=:variable, value_name::Symbol=:value, view::Bool=false)` is deprecated, use `stack(df, Not(id_vars); variable_name=variable_name, value_name=value_name, view=view)` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:93
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:93
┌ Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:96
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:96
┌ Warning: `getindex(df::DataFrame, col_ind::ColumnIndex)` is deprecated, use `df[!, col_ind]` instead.
│   caller = #plot#1(::Symbol, ::Nothing, ::Array{Any,1}, ::MinAICc, ::Array{SegSelect,1}, ::typeof(plot), ::LassoPath{LinearModel{GLM.LmResp{Array{Float64,1}},CovarianceCoordinateDescent{Float64,true,Array{Float64,2},Lasso.RandomCoefficientIterator,Nothing}},Float64}) at plots.jl:97
└ @ LassoPlot ~/.julia/packages/LassoPlot/J9WEN/src/plots.jl:97

julia> using Pkg; Pkg.status()
    Status `/tmp/Project.toml`
  [a93c6f00] DataFrames v0.20.0
  [b4fcebef] Lasso v0.5.0
  [21d151f5] LassoPlot v1.1.0
AsafManela commented 4 years ago

No worries. Happens to me often. Glad it worked out.