From 4b774fbf4b41cb8618285a9d4daea233c209a432 Mon Sep 17 00:00:00 2001 From: Rik Huijzer Date: Mon, 4 Dec 2023 11:12:05 +0100 Subject: [PATCH] Remove check for feature in `feature_importance` --- src/importance.jl | 5 ----- test/importance.jl | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/importance.jl b/src/importance.jl index a7c252e..b8e2123 100644 --- a/src/importance.jl +++ b/src/importance.jl @@ -35,19 +35,14 @@ function feature_importance( feat_name::String ) importance = 0.0 - found_feature = false for (i, rule) in enumerate(model.rules) for subclause::SubClause in subclauses(rule) if feature_name(subclause)::String == feat_name - found_feature = true weight = model.weights[i] importance += _rule_importance(weight, rule) end end end - if !found_feature - 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 73f3d58..08d1659 100644 --- a/test/importance.jl +++ b/test/importance.jl @@ -19,11 +19,6 @@ end # and 2 classes: [0, 1]. # Note: showing only the probability for class 1 since class 0 has probability 1 - p. -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. expected = w1 * (0.4 - 0.1) + w2 * (0.3 - 0.2)