AsafManela / LassoPlot.jl

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

using recipes #11

Open mkborregaard opened 3 years ago

mkborregaard commented 3 years ago

Hi, would it be possible/interesting to factor this package down to just using recipes rather importing all of Plots and StatsPlots (two rather heavy dependencies, in particular StatsPlots). That is the intended usage of Plots - or are there special considerations to take in terms of the needs of this package?

AsafManela commented 3 years ago

I think you are correct that recipes is the proper way to go. Contributions welcome.

mkborregaard commented 3 years ago

Yeah fair enough. I don't mind trying to write the recipes but can you help a little with you are needing to do exactly here? I see your plot code includes @df - can that data be taken from the Lasso objects instead so we only need to depend on Lasso?

AsafManela commented 3 years ago

It does come from Lasso objects. If I remember correctly, the df is there because before Plots it depended on Gadfly which is all about dfs.

mkborregaard commented 3 years ago

Can you provide a runnable example of this package I can use as a target? None of the examples here provide sample data. I tried picking data out of one of your examples, but it would be nice to see the full range of intended functionality.

I just fell over this package and just assumed it's user ready - is it work in progress or something that can be broadly used right now? I'm asking because I am a little in doubt whether it should also be able to plot LassoModel objects, and LassoPath objects wrapped in StatsModels types?

AsafManela commented 3 years ago

Sure, try this one:

using DataFrames, Plots, Lasso, LassoPlot, Random
n = 100
x = rand(n)
data = DataFrame(X=x, Y=x + rand(n))
m = fit(LassoPath, @formula(Y ~ X), data)
plot(m.model)

Note that sample size n has to be large enough for 10-fold cross validation to not complain about k being too large. If you want to stay with a small sample, you can try specifying which selectors (vertical lines) to show like here:

plot(m.model, showselectors=[MinAICc()])

About plotting StatsModels types, I think adding those methods makes sense.