From 68b401a0ead6087f098daf0eb5587243fb1dbc55 Mon Sep 17 00:00:00 2001 From: tiemvanderdeure Date: Thu, 31 Oct 2024 15:33:04 +0100 Subject: [PATCH 1/8] do not unwrap categorical column --- src/encoders.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoders.jl b/src/encoders.jl index f396142..58f2822 100644 --- a/src/encoders.jl +++ b/src/encoders.jl @@ -67,7 +67,7 @@ function ordinal_encoder_transform(X, mapping_matrix) test_levels = levels(col) check_unkown_levels(train_levels, test_levels) level2scalar = mapping_matrix[ind] - new_col = recode(unwrap.(col), level2scalar...) + new_col = recode(col, level2scalar...) push!(new_feats, new_col) else push!(new_feats, col) From 3315da44ae0e8f8a6ec3e9446507c1221f7116cf Mon Sep 17 00:00:00 2001 From: tiemvanderdeure Date: Thu, 31 Oct 2024 15:58:36 +0100 Subject: [PATCH 2/8] convert to Float32 in predict --- src/classifier.jl | 4 ++-- src/regressor.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/classifier.jl b/src/classifier.jl index 036602c..725697a 100644 --- a/src/classifier.jl +++ b/src/classifier.jl @@ -40,7 +40,7 @@ function MLJModelInterface.predict( ) chain, levels, ordinal_mappings, _ = fitresult Xnew = ordinal_encoder_transform(Xnew, ordinal_mappings) # what if Xnew is a matrix - X = reformat(Xnew) + X = _f32(reformat(Xnew), 0) probs = vcat([chain(tomat(X[:, i]))' for i in 1:size(X, 2)]...) return MLJModelInterface.UnivariateFinite(levels, probs) end @@ -69,7 +69,7 @@ function MLJModelInterface.predict( ) chain, levels, ordinal_mappings, _ = fitresult Xnew = ordinal_encoder_transform(Xnew, ordinal_mappings) - X = reformat(Xnew) + X = _f32(reformat(Xnew), 0) probs = vec(chain(X)) return MLJModelInterface.UnivariateFinite(levels, probs; augment = true) end diff --git a/src/regressor.jl b/src/regressor.jl index 1fd9bcb..818ad87 100644 --- a/src/regressor.jl +++ b/src/regressor.jl @@ -27,7 +27,7 @@ function MLJModelInterface.predict(model::NeuralNetworkRegressor, Xnew) chain, ordinal_mappings = fitresult[1], fitresult[3] Xnew = ordinal_encoder_transform(Xnew, ordinal_mappings) - Xnew_ = reformat(Xnew) + Xnew_ = _f32(reformat(Xnew), 0) return [chain(values.(tomat(Xnew_[:, i])))[1] for i in 1:size(Xnew_, 2)] end @@ -74,7 +74,7 @@ function MLJModelInterface.predict(model::MultitargetNeuralNetworkRegressor, fitresult, Xnew) chain, target_column_names, ordinal_mappings, _ = fitresult Xnew = ordinal_encoder_transform(Xnew, ordinal_mappings) - X = reformat(Xnew) + X = _f32(reformat(Xnew), 0) ypred = [chain(values.(tomat(X[:, i]))) for i in 1:size(X, 2)] output = From 268afad30f0b057f27f9c1fa03f667bca42482a7 Mon Sep 17 00:00:00 2001 From: tiemvanderdeure Date: Fri, 1 Nov 2024 10:28:44 +0100 Subject: [PATCH 3/8] unwrap after recoding --- src/encoders.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/encoders.jl b/src/encoders.jl index 58f2822..1a058e9 100644 --- a/src/encoders.jl +++ b/src/encoders.jl @@ -67,7 +67,7 @@ function ordinal_encoder_transform(X, mapping_matrix) test_levels = levels(col) check_unkown_levels(train_levels, test_levels) level2scalar = mapping_matrix[ind] - new_col = recode(col, level2scalar...) + new_col = unwrap.(recode(col, level2scalar...)) push!(new_feats, new_col) else push!(new_feats, col) From 4d9fb34b25cfc3ad20bc16759e7a1b1b8b9e66b6 Mon Sep 17 00:00:00 2001 From: Okon Samuel <39421418+OkonSamuel@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:02:05 +0100 Subject: [PATCH 4/8] Update ci.yml --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a396f92..f613f85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,10 +4,12 @@ on: branches: - master - dev + - fixb push: branches: - master - dev + - fixb tags: '*' jobs: test: From de948445e1a4d9ce008b874cad6677604e169d05 Mon Sep 17 00:00:00 2001 From: Okon Samuel <39421418+OkonSamuel@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:47:44 +0100 Subject: [PATCH 5/8] fix failing test --- test/mlj_model_interface.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/mlj_model_interface.jl b/test/mlj_model_interface.jl index 7984990..49febe1 100644 --- a/test/mlj_model_interface.jl +++ b/test/mlj_model_interface.jl @@ -133,6 +133,13 @@ mutable struct LisasBuilder n1::Int end +# UndefVarError accepts two inputs from julia > v"1.9" +_UndefVarError(var, scope) = @static if VERSION <= v"1.9" + UndefVarError(var) +else + UndefVarError(var, scope) +end + @testset "builder errors and issue #237" begin # create a builder with an intentional flaw; # `Chains` is undefined - it should be `Chain` @@ -153,7 +160,7 @@ end y = rand(Float32, 75) @test_logs( (:error, MLJFlux.ERR_BUILDER), - @test_throws UndefVarError(:Chains) MLJBase.fit(model, 0, X, y) + @test_throws _UndefVarError(:Chains, Flux) MLJBase.fit(model, 0, X, y) ) end From a630c52396f2fdd75e3b5f750f67b63f13536e56 Mon Sep 17 00:00:00 2001 From: Okon Samuel <39421418+OkonSamuel@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:57:32 +0100 Subject: [PATCH 6/8] Update mlj_model_interface.jl --- test/mlj_model_interface.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/mlj_model_interface.jl b/test/mlj_model_interface.jl index 49febe1..bc74583 100644 --- a/test/mlj_model_interface.jl +++ b/test/mlj_model_interface.jl @@ -134,7 +134,7 @@ mutable struct LisasBuilder end # UndefVarError accepts two inputs from julia > v"1.9" -_UndefVarError(var, scope) = @static if VERSION <= v"1.9" +_UndefVarError(var, scope) = @static if VERSION < v"1.10" UndefVarError(var) else UndefVarError(var, scope) From d42dbccbcba960680274541eb97148fdeacfcb48 Mon Sep 17 00:00:00 2001 From: Okon Samuel <39421418+OkonSamuel@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:13:49 +0100 Subject: [PATCH 7/8] Update ci.yml --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f613f85..a396f92 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,12 +4,10 @@ on: branches: - master - dev - - fixb push: branches: - master - dev - - fixb tags: '*' jobs: test: From 318a61e821d37b07e5c9c97a5bc08735ffa60c37 Mon Sep 17 00:00:00 2001 From: "Anthony D. Blaom" Date: Thu, 14 Nov 2024 08:56:43 +1300 Subject: [PATCH 8/8] bump 0.6.1 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4a23524..bcddeca 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "MLJFlux" uuid = "094fc8d1-fd35-5302-93ea-dabda2abf845" authors = ["Anthony D. Blaom ", "Ayush Shridhar "] -version = "0.6.0" +version = "0.6.1" [deps] CategoricalArrays = "324d7699-5711-5eae-9e2f-1d82baa6b597"