Record Class EnsembleSelection
java.lang.Object
java.lang.Record
smile.feature.selection.EnsembleSelection
- Record Components:
feature- The feature name.importance- The variable importance score.
- All Implemented Interfaces:
Comparable<EnsembleSelection>
public record EnsembleSelection(String feature, double importance)
extends Record
implements Comparable<EnsembleSelection>
Feature selection using tree ensemble models (such as Random Forest or
Gradient Tree Boost).
Ensemble methods measure the importance of features by aggregating the impurity decrease (such as Gini impurity or variance reduction) across all trees in the ensemble. Features that appear frequently in splits yielding large impurity reductions achieve higher importance scores.
-
Constructor Summary
ConstructorsConstructorDescriptionEnsembleSelection(String feature, double importance) Creates an instance of aEnsembleSelectionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(EnsembleSelection other) final booleanIndicates whether some other object is "equal to" this one.feature()Returns the value of thefeaturerecord component.static EnsembleSelection[]Fits an ensemble model to calculate feature importance scores.static EnsembleSelection[]fit(DataFrame data, String response, Properties props) Fits an ensemble model to calculate feature importance scores with hyperparameter options.static EnsembleSelection[]Fits an ensemble model to calculate feature importance scores.static EnsembleSelection[]fit(Formula formula, DataFrame data, Properties props) Fits an ensemble model to calculate feature importance scores with hyperparameter options.final inthashCode()Returns a hash code value for this object.doubleReturns the value of theimportancerecord component.static EnsembleSelection[]of(DataFrameClassifier model) Extracts ensemble selection scores from a trained classification model.static EnsembleSelection[]of(StructType schema, double[] importance) Constructs ensemble feature selection scores from a feature schema and importance vector.static EnsembleSelection[]of(DataFrameRegression model) Extracts ensemble selection scores from a trained regression model.static String[]threshold(EnsembleSelection[] scores, double minImportance) Returns the names of features with importance score greater than or equal to a threshold, sorted in descending order of importance.static String[]top(EnsembleSelection[] scores, int k) Returns the names of the topkfeatures in descending order of importance.toString()Returns a string representation of this record class.
-
Constructor Details
-
EnsembleSelection
Creates an instance of aEnsembleSelectionrecord class.- Parameters:
feature- the value for thefeaturerecord componentimportance- the value for theimportancerecord component
-
-
Method Details
-
compareTo
- Specified by:
compareToin interfaceComparable<EnsembleSelection>
-
toString
-
of
Constructs ensemble feature selection scores from a feature schema and importance vector.- Parameters:
schema- the predictors schema.importance- the importance scores corresponding to each schema field.- Returns:
- an array of ensemble selection scores.
-
of
Extracts ensemble selection scores from a trained classification model.- Parameters:
model- the trained classification model.- Returns:
- an array of ensemble selection scores.
-
of
Extracts ensemble selection scores from a trained regression model.- Parameters:
model- the trained regression model.- Returns:
- an array of ensemble selection scores.
-
fit
Fits an ensemble model to calculate feature importance scores. Automatically chooses classification or regression based on the response variable type.- Parameters:
formula- a symbolic description of the model to be fitted.data- the data frame of explanatory and response variables.- Returns:
- an array of ensemble selection scores.
-
fit
Fits an ensemble model to calculate feature importance scores with hyperparameter options. Automatically chooses classification or regression based on the response variable type.- Parameters:
formula- a symbolic description of the model to be fitted.data- the data frame of explanatory and response variables.props- the hyperparameters.- Returns:
- an array of ensemble selection scores.
-
fit
Fits an ensemble model to calculate feature importance scores.- Parameters:
data- the data frame of explanatory and response variables.response- the column name of the response variable.- Returns:
- an array of ensemble selection scores.
-
fit
Fits an ensemble model to calculate feature importance scores with hyperparameter options.- Parameters:
data- the data frame of explanatory and response variables.response- the column name of the response variable.props- the hyperparameters.- Returns:
- an array of ensemble selection scores.
-
top
Returns the names of the topkfeatures in descending order of importance.- Parameters:
scores- the ensemble selection scores.k- the number of top features to return.- Returns:
- the top
kfeature names.
-
threshold
Returns the names of features with importance score greater than or equal to a threshold, sorted in descending order of importance.- Parameters:
scores- the ensemble selection scores.minImportance- the minimum importance threshold.- Returns:
- the selected feature names.
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
feature
-
importance
public double importance()Returns the value of theimportancerecord component.- Returns:
- the value of the
importancerecord component
-