-
Notifications
You must be signed in to change notification settings - Fork 156
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
Visualization tool for one and two-parameter tuning #85
Comments
Do you think using UnicodePlots may make some sense here so that one could keep working in a REPL? It's also much faster and for simple visualisations it may be enough? In a similar vein there's PrettyTables.jl a lightweight package to quickly visualise dataframes and highlight elements which might be good too (for quickly showing benchmark results for instance, highlighting the best scores according to a range of metrics) Possibly the visualisation could be inferred from the environment so that if one is in Juno or IJulia, richer multimedia tools are used? |
UnicodePlots is also a plots.jl backend. I would recommend having plot recipes for plots.jl and then eventually makie. Then the user can choose the backend Edit: Maybe @mkborregaard can discuss his experiences with statsplots and how they might help here. |
All sound good to me. I'm leaving this one for someone else to implement! |
I agree that recipes would be a good choice. There are recipes in MCMCChain that I helped develop https://github.com/TuringLang/MCMCChain.jl/blob/master/src/plot.jl which might be similar to what is required here? |
Regarding "tuning plots", it might be best to dispatch the plot method on the fitted model? Though I see issues with what the default would do:
One thing that the user also expects are "learning curves", though not all models may return these. Maybe separate the grid tuning plot from the learning curves? |
I think that in MLR uses bubbles on the grid points (for 2d case). The bubble radius reflects the performance estimate. Maybe that's a better fallback?? @mkborregaard That would be awesome if you could contribute. Some technical detail for implementers:
What you'll want is:
|
Sounds good. Could you provide an example of the kind of end result plot you have in mind? |
Here is the aforementioned example of a bubble plot from MLR but I'm not fixed on this if others want to chime in with a different suggestion. Since performance estimates are generally close together, a proportional bubble size obviously doesn't work (ie some recentring/rescaling is called for). By default, add the following annotations (in title?): the value of |
Looks good, just a small note: aren't the axes mislabelled? Since should C/sigma in SVM not always be positive? These are probably the untransformed values, or log(C) and log(sigma) for some logarithm basis. Is this a bug in mlr? |
Dunno. Just copied and pasted from MLR slides |
Hm, also, shouldn't "area under the (ROC) curve" be at least 0.5? Something is fishy in this plot... Anyway, I personally like the heatplot more for this purpose, but that's really just a matter of taste. |
hm, would it look better if you:
|
But if it were to be general, would that require examining the object somehow to see that one axis was log spaced, then scale that? |
That's nice! Just chipping in but it seems to me quite common that models can end up having very similar performances for a range of hyperparameter especially trivial models like KNN so it's probably fair to just return a flat landscape where that's the case. That being it seems to me KNN will in general only vary for very low K (so from K=1 to K=10 maybe) so maybe the range shown here on plots is a bit too big? Finally I feel the first heatmap is the visualisation that is the clearest out of the ones posted here but maybe just personal preference. |
IMO 3D plots look cool but are in general hard to read. Also with the idea that we could potentially have MLJ revert to UnicodePlots backend in a "fully-REPL-mode", 3D would not be the best option I think? |
I agree with your first point in principle, but not, in fact, for fitting surfaces. Anyway, the heatmap recipe would allow the user to default to |
This might highlight the challenge of determining proper axis ranges (or dot size ranges). Scale at min/max plusminus epsilon might be necessary. |
The scale used is part of the information accessible to you from the TunedModel object. Because of the nested nature of the hyperparameters, it is not in the most convenient form for 2D plotting but I will work on this over the next day or so. I will arrange to have the scales output as |
Okay, scales are now available; see issue #92 for details and example. |
And did you prefer the heatmap or the dots? Which of the above appeals? |
@mkborregaard Marvellous work, by the way. I guess I prefer the bubbles as a default because you can see where the samples were actually taken and, at a glance, what the resolution was, and so forth. Also a bubble size is immediately understood - a colour needs to be interpreted. Despite your concern for "honest" reproduction, I would rescale as others have also suggested. How else can I distinguish estimates that are typically very close together? A really honest plot would have an indication of uncertainty of estimate at each point (available in principle in cv case but not holdout) but I think these plots serve more of a diagnostic purpose than a final reporting one, no? That said, I do not have a strong preference and you are never going to please everyone. As long as I can quickly see where the low or unusual points are, I am happy. Side issue: How would we present a a 2D parameter plot using UnicodePlots? I would love the option of a REPL plot without having to load the Plots.jl frontend first (regular pain!!). BTW: The log plot spacing is not uniform in your bubble plot above because K is integer valued. So rounding forces non-uniform spacing on the log scale. So, this is just the way it is; nothing wrong with using the log scale there (which was the scale used to generate the grid). |
Hm, plot-wise I think heatmap is the clearest, with surface plot also not bad - though more difficult to read and objectively compare z-values. @ablaom , regarding uncertainty estimate - absolutely agreed. But it is unclear how to show it in a 2D heatmap or a 3D plot - uncertainty envelopes/tunnels are however good to show in an 1D plot performance-vs-parameter_value (if there's one parameter only). Which brings us to the topic how to compute confidence intervals/Regions, one of my favourite topics that you should not have gotten me started on. Spoiler: I don't think using cross-validation re-samples gives good confidence intervals. |
Me too!
Look forward to discussion at meeting next week. |
@mkborregaard Please note that reports have just become named tuples. So accesss is by property not index. See NEWS.md. |
I've got to say I'm spending almost all of the time here searching for a way to generate the object you want plotted, rather than with coming up with a recipe. The old one I had generated from your readme doesn't work anymore, and the tuned model generated on your tour doesn't seem to be of them type you're interested in. There's an example over in #92, but it's missing something called |
@mkborregaard thanks for the feedback - this might be taken to mean that the interface for inspecting fitted models may have to be improved, in general - see ongoing #51 discussion. Thus, it might make sense to assume you have the data already in a nice format, and wait for the interface extension to give the objects nicely to you, rather than find the best way to pry it from the learning machine's cold, dead hands. Unless, of course, @ablaom recommends another way to proceed. |
I'm sorry to hear about your frustrations. The main issue I believe is the unlucky breaking change in the format of
I'm interested in this example. I have posted a distilled, complete, and tested version of the tour example, showing how to get everything I expect you need. You need to update your MLJ installation (including MLJBase and MLJModels) to the version posted about 17 hours ago to get it to work but let me know if you have problems. I doubt very much there will be further API changes in the foreseeable future that will break code based on this example. Let me know if and when you decide to have another go and thanks again for the work so far. Your method (adapted into recipe) will look something like function plot(mach::MLJ.Machine{<:MLJ.EitherTunedModel})
r = report(mach)
xlab, ylab = r.parameter_names
xscale, yscale = r.parameter_scales
x = r.parameter_values[:,1]
y = r.parameter_values[:,2]
z = r.measurements
<code to generate plot>
end
|
Thanks for making it so easy for me now - I'll post the recipe as soon as I have a moment :-) |
I find it quite useful to visualize hyper-parameter tuning for more parameters than 2 as well. Simply plotting ranges vs function values for all parameters is a reasonable way of presenting the information. You can't determine interaction between parameters from this, but you can see overall trends for individual parameters and it quickly becomes apparent if one parameter is much more important than the others |
@baggepinnen 's plot looks nice. Should this issue have been closed though? |
closed in favour of #416 |
Would be nice to have some visualization tools (Plots.jl recipes?) for looking at the results of one or two-parameter tuning, as ouput in the
report
field of aTunedModel
machine.This might be as simple as adding a suitable instruction to the tuning doc string on how to call an existing recipe.
The text was updated successfully, but these errors were encountered: