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

WIP + RFC. Add simple plotting recipe. Fix #85 #99

Merged
merged 1 commit into from
Mar 12, 2019

Conversation

mkborregaard
Copy link
Contributor

No description provided.

@mkborregaard
Copy link
Contributor Author

mkborregaard commented Mar 7, 2019

A simple recipe for plotting. Right now it's the default plot for tuned models, that can be changed if that is not desired. It uses colored scatter points. There's an option for using heatmap also, but that currently behaves strangely for log scales. That seems to be a bug in Plots though, I think the recipe here is fine.

Using the tuned_ensemble object generated from here, you can do:

plot(tuned_ensemble)

tune1

The heatmap version (you can also use surface or contour):

heatmap(tuned_model)

tune2

@ablaom
Copy link
Member

ablaom commented Mar 7, 2019

This looks super.

I'm having some problems though. Any ideas?

I'm using Plots.jl v0.23.1

julia> using Plots
julia> Plots.backend()
Plots.GRBackend()

julia> include("examples/two_parameter_tune.jl")
julia> tuned_ensemble isa MLJ.Machine{<:MLJ.EitherTunedModel}
true

julia> plot(tuned_ensemble)
ERROR: No user recipe defined for Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] convertToAnyVector(::Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}, ::Dict{Symbol,Any}) at /Users/anthony/.julia/packages/Plots/gylTh/src/series.jl:14
 [3] macro expansion at /Users/anthony/.julia/packages/Plots/gylTh/src/series.jl:139 [inlined]
 [4] apply_recipe(::Dict{Symbol,Any}, ::Type{Plots.SliceIt}, ::Nothing, ::Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}, ::Nothing) at /Users/anthony/.julia/packages/RecipesBase/Uz5AO/src/RecipesBase.jl:275
 [5] _process_userrecipes(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}}) at /Users/anthony/.julia/packages/Plots/gylTh/src/pipeline.jl:83
 [6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}}) at /Users/anthony/.julia/packages/Plots/gylTh/src/plot.jl:178
 [7] #plot#136(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}) at /Users/anthony/.julia/packages/Plots/gylTh/src/plot.jl:57
 [8] plot(::Machine{MLJ.DeterministicTunedModel{Grid,DeterministicEnsembleModel{Tuple{Array{Float64,2},Array{Float64,1}},KNNRegressor{Float64}}}}) at /Users/anthony/.julia/packages/Plots/gylTh/src/plot.jl:51
 [9] top-level scope at none:0

julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i5-3427U CPU @ 1.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, ivybridge)
Environment:
  JULIA_PATH = /Applications/Julia-1.0.app/Contents/Resources/julia/bin/julia

Edit Maybe add above code as test and see if Travis also dies?

@mkborregaard
Copy link
Contributor Author

Sure I've added the suggested test, though this adds Plots as a testing dependency.
It looks like you may just not have the right branch checked out though.

@mkborregaard
Copy link
Contributor Author

Seems to work for Travis.

@ablaom
Copy link
Member

ablaom commented Mar 8, 2019

Yes, my mistake. In a recent rebuild of my working env I had done add instead of dev of the MLJ repos. It works great.

I'd like to pull this before adding a 1-parameter version (there was some discussion of adding uncertainty estimates in this case). @mkborregaard Could you please:

  • add a check on the number of parameters and do error("Only two-parameter tuning plots supported. ") if the number is not two?

  • remove the test and Plots dependency

@fkiraly Are you happy for me to pull this?

@mkborregaard
Copy link
Contributor Author

I can - just to make sure, the test doesn't add Plots as a dependency, just as a test dependency. But you'd still like me to remove it again?

@ablaom
Copy link
Member

ablaom commented Mar 8, 2019

Yes, let's leave it out for now thanks.

add plot recipe


Revert "add dep on RecipesBase"

This reverts commit 4a08062.

clean up manifest


add test


revert add test
@ablaom ablaom merged commit 977f4c3 into JuliaAI:master Mar 12, 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

Successfully merging this pull request may close these issues.

2 participants