From 0bcae0863d2d2e0591c071ae157721f0c96786b9 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 25 Jun 2020 14:55:32 +1200 Subject: [PATCH 1/2] extend [compat] MLJBase = "^0.12.2,^0.13,^0.14" --- Project.toml | 2 +- test/models/simple_composite_model.jl | 7 ++++--- test/strategies/grid.jl | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index 80a71dd..7c10a43 100644 --- a/Project.toml +++ b/Project.toml @@ -16,7 +16,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" [compat] ComputationalResources = "^0.3" Distributions = "^0.22,^0.23" -MLJBase = "^0.12.2,^0.13" +MLJBase = "^0.12.2,^0.13,^0.14" MLJModelInterface = "^0.3" ProgressMeter = "^1.3" RecipesBase = "^0.8,^0,9,^1.0" diff --git a/test/models/simple_composite_model.jl b/test/models/simple_composite_model.jl index e1985aa..1816c9f 100644 --- a/test/models/simple_composite_model.jl +++ b/test/models/simple_composite_model.jl @@ -36,7 +36,7 @@ MLJBase.is_wrapper(::Type{<:SimpleDeterministicCompositeModel}) = true function MLJBase.fit(composite::SimpleDeterministicCompositeModel, verbosity::Integer, Xtrain, ytrain) X = source(Xtrain) # instantiates a source node - y = source(ytrain, kind=:target) + y = source(ytrain) t = machine(composite.transformer, X) Xt = transform(t, X) @@ -44,9 +44,10 @@ function MLJBase.fit(composite::SimpleDeterministicCompositeModel, l = machine(composite.model, Xt, y) yhat = predict(l, Xt) - fit!(yhat, verbosity=verbosity) + mach = machine(Deterministic(), X, y; predict=yhat) + fit!(mach, verbosity=verbosity) - return fitresults(yhat) + return mach() end MLJBase.load_path(::Type{<:SimpleDeterministicCompositeModel}) = diff --git a/test/strategies/grid.jl b/test/strategies/grid.jl index 54308af..41fe80f 100644 --- a/test/strategies/grid.jl +++ b/test/strategies/grid.jl @@ -153,12 +153,13 @@ end fit!(tuned, verbosity=0) r = report(tuned) - @test r.best_report isa NamedTuple{(:machines, :report_given_machine)} + @test r.best_report isa + NamedTuple{(:model, :transformer, :report_given_machine)} fit!(tuned, verbosity=0) rep = report(tuned) fp = fitted_params(tuned) @test fp.best_fitted_params isa - NamedTuple{(:machines, :fitted_params_given_machine)} + NamedTuple{(:model, :transformer, :fitted_params_given_machine)} b = fp.best_model @test b isa SimpleDeterministicCompositeModel From 187705bdc2b535c34892e87b124903f3f1576165 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 25 Jun 2020 18:29:59 +1200 Subject: [PATCH 2/2] adjustments to MLJBase 0.14 --- Project.toml | 2 +- test/strategies/grid.jl | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Project.toml b/Project.toml index 7c10a43..9ac38ef 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJTuning" uuid = "03970b2e-30c4-11ea-3135-d1576263f10f" authors = ["Anthony D. Blaom "] -version = "0.3.7" +version = "0.4.0" [deps] ComputationalResources = "ed09eef8-17a6-5b46-8889-db040fac31e3" diff --git a/test/strategies/grid.jl b/test/strategies/grid.jl index 41fe80f..b949ff0 100644 --- a/test/strategies/grid.jl +++ b/test/strategies/grid.jl @@ -153,13 +153,11 @@ end fit!(tuned, verbosity=0) r = report(tuned) - @test r.best_report isa - NamedTuple{(:model, :transformer, :report_given_machine)} + @test :model in collect(keys(r.best_report)) fit!(tuned, verbosity=0) rep = report(tuned) fp = fitted_params(tuned) - @test fp.best_fitted_params isa - NamedTuple{(:model, :transformer, :fitted_params_given_machine)} + @test :model in collect(keys(fp.best_fitted_params)) b = fp.best_model @test b isa SimpleDeterministicCompositeModel