@@ -48,6 +48,7 @@ It recursively removes features, training a base model on the remaining features
4848evaluating their importance until the desired number of features is selected.
4949
5050# Training data
51+
5152In MLJ or MLJBase, bind an instance `rfe_model` to data with
5253
5354 mach = machine(rfe_model, X, y)
@@ -95,13 +96,17 @@ Train the machine using `fit!(mach, rows=...)`.
9596 table.
9697
9798# Fitted parameters
99+
98100The fields of `fitted_params(mach)` are:
101+
99102- `features_left`: names of features remaining after recursive feature elimination.
100103
101104- `model_fitresult`: fitted parameters of the base model.
102105
103106# Report
107+
104108The fields of `report(mach)` are:
109+
105110- `scores`: dictionary of scores for each feature in the training dataset.
106111 The model deems highly scored variables more significant.
107112
@@ -215,22 +220,30 @@ abs_last(x::Pair{<:Any, <:Real}) = abs(last(x))
215220"""
216221 score_features!(scores_dict, features, importances, n_features_to_score)
217222
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
219226importance and store the features in the `features` array.
220227
221228# Arguments
229+
222230- `scores_dict::Dict{Symbol, Int}`: A dictionary where the keys are features and
223231 the values are their corresponding scores.
232+
224233- `features::Vector{Symbol}`: An array to store the top features based on importance.
234+
225235- `importances::Vector{Pair(Symbol, <:Real)}}`: An array of tuples where each tuple
226236 contains a feature and its importance score.
237+
227238- `n_features_to_score::Int`: The number of top features to score and store.
228239
229240# Notes
241+
230242Ensure that `n_features_to_score` is less than or equal to the minimum of the
231243lengths of `features` and `importances`.
232244
233245# Example
246+
234247```julia
235248scores_dict = Dict(:feature1 => 0, :feature2 => 0, :feature3 => 0)
236249features = [:x1, :x1, :x1]
0 commit comments