@@ -48,6 +48,7 @@ It recursively removes features, training a base model on the remaining features
48
48
evaluating their importance until the desired number of features is selected.
49
49
50
50
# Training data
51
+
51
52
In MLJ or MLJBase, bind an instance `rfe_model` to data with
52
53
53
54
mach = machine(rfe_model, X, y)
@@ -95,13 +96,17 @@ Train the machine using `fit!(mach, rows=...)`.
95
96
table.
96
97
97
98
# Fitted parameters
99
+
98
100
The fields of `fitted_params(mach)` are:
101
+
99
102
- `features_left`: names of features remaining after recursive feature elimination.
100
103
101
104
- `model_fitresult`: fitted parameters of the base model.
102
105
103
106
# Report
107
+
104
108
The fields of `report(mach)` are:
109
+
105
110
- `scores`: dictionary of scores for each feature in the training dataset.
106
111
The model deems highly scored variables more significant.
107
112
@@ -215,22 +220,30 @@ abs_last(x::Pair{<:Any, <:Real}) = abs(last(x))
215
220
"""
216
221
score_features!(scores_dict, features, importances, n_features_to_score)
217
222
218
- Internal method that updates the `scores_dict` by increasing the score for each feature based on their
223
+ **Private method.**
224
+
225
+ Update the `scores_dict` by increasing the score for each feature based on their
219
226
importance and store the features in the `features` array.
220
227
221
228
# Arguments
229
+
222
230
- `scores_dict::Dict{Symbol, Int}`: A dictionary where the keys are features and
223
231
the values are their corresponding scores.
232
+
224
233
- `features::Vector{Symbol}`: An array to store the top features based on importance.
234
+
225
235
- `importances::Vector{Pair(Symbol, <:Real)}}`: An array of tuples where each tuple
226
236
contains a feature and its importance score.
237
+
227
238
- `n_features_to_score::Int`: The number of top features to score and store.
228
239
229
240
# Notes
241
+
230
242
Ensure that `n_features_to_score` is less than or equal to the minimum of the
231
243
lengths of `features` and `importances`.
232
244
233
245
# Example
246
+
234
247
```julia
235
248
scores_dict = Dict(:feature1 => 0, :feature2 => 0, :feature3 => 0)
236
249
features = [:x1, :x1, :x1]
0 commit comments