From b38fd0c51c7004dc116dbc1e62f5d4dc1a96802c Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 4 Dec 2023 11:08:10 +0100 Subject: [PATCH] Fix `feature_importance` error message --- Project.toml | 2 +- src/importance.jl | 2 +- test/importance.jl | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 935bbd0..d327f75 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "SIRUS" uuid = "cdeec39e-fb35-4959-aadb-a1dd5dede958" authors = ["Rik Huijzer "] -version = "2.0.0" +version = "2.0.1" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/src/importance.jl b/src/importance.jl index c400561..a7c252e 100644 --- a/src/importance.jl +++ b/src/importance.jl @@ -46,7 +46,7 @@ function feature_importance( end end if !found_feature - throw(ArgumentError("Feature `$feature_name` not found in the model.")) + throw(ArgumentError("Feature `$feat_name` not found in the model.")) end return importance end diff --git a/test/importance.jl b/test/importance.jl index 80cd64c..73f3d58 100644 --- a/test/importance.jl +++ b/test/importance.jl @@ -19,7 +19,10 @@ end # and 2 classes: [0, 1]. # Note: showing only the probability for class 1 since class 0 has probability 1 - p. -@test_throws ArgumentError feature_importance(model, "x1") +let + msg = "Feature `x1` not found in the model." + @test_throws ArgumentError(msg) feature_importance(model, "x1") +end importance = feature_importance(model, "1") # Based on the numbers above.