Skip to content

Commit

Permalink
add dep on RecipesBase
Browse files Browse the repository at this point in the history
add plot recipe


Revert "add dep on RecipesBase"

This reverts commit 4a08062.

clean up manifest


add test


revert add test
  • Loading branch information
mkborregaard committed Mar 12, 2019
1 parent ebc4df6 commit 977f4c3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[[RecipesBase]]
deps = ["Random", "Test"]
git-tree-sha1 = "0b3cb370ee4dc00f47f1193101600949f3dcf884"
uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
version = "0.6.0"

[[Reexport]]
deps = ["Pkg"]
git-tree-sha1 = "7b1d07f411bc8ddb7977ec7f377b97b158514fe0"
Expand Down
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ MLJModels = "d491faf4-2d78-11e9-2867-c94bc002c0b7"
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
RemoteFiles = "cbe49d4c-5af1-5b60-bb70-0a60aa018e1b"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Expand Down
6 changes: 6 additions & 0 deletions src/MLJ.jl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ using LinearAlgebra
using Random
import Distributed: @distributed, nworkers, pmap

# for plotting
using RecipesBase

const srcdir = dirname(@__FILE__) # the directory containing this file:

include("utilities.jl") # general purpose utilities
Expand Down Expand Up @@ -104,5 +107,8 @@ include("builtins/LocalMultivariateStats.jl")
include("loading.jl") # model metadata processing


## SIMPLE PLOTTING RECIPE

include("plotrecipes.jl")

end # module
28 changes: 28 additions & 0 deletions src/plotrecipes.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@recipe function f(mach::MLJ.Machine{<:MLJ.EitherTunedModel})
r = report(mach)
z = r.measurements
x = r.parameter_values[:,1]
y = r.parameter_values[:,2]
xsc, ysc = r.parameter_scales

xguide --> r.parameter_names[1]
yguide --> r.parameter_names[2]
xscale --> (xsc == :linear ? :identity : xsc)
yscale --> (ysc == :linear ? :identity : ysc)

st = get(plotattributes, :seriestype, :scatter)

if st (:surface, :heatmap, :contour, :contourf, :wireframe)
ux = unique(x)
uy = unique(y)
m = reshape(z, (length(ux), length(uy)))'
ux, uy, m
else
label --> ""
seriestype := st
ms = get(plotattributes, :markersize, 4)
markersize := 3ms * sqrt.(z)
marker_z --> z
x, y
end
end

0 comments on commit 977f4c3

Please sign in to comment.