Trace Ratio¶
skfeature.function.similarity_based.trace_ratio
Description¶
Trace Ratio performs supervised feature selection by optimizing the trace ratio criterion, max trace(Sb) / trace(Sw), where Sb and Sw are the between-class and within-class scatter matrices. It supports a fisher or laplacian style for building the scatter matrices.
Usage¶
import numpy as np
from sklearn.datasets import load_iris
from skfeature.function.similarity_based import trace_ratio
X, y = load_iris(return_X_y=True)
# rank features with the trace ratio criterion
score = trace_ratio.trace_ratio(X, y)
Parameters¶
X:numpy array, shape(n_samples, n_features)— input datay:numpy array, shape(n_samples,)— class labelsn_selected_features:int— number of features to select**kwargs:style("fisher"or"laplacian") andverbosemode:{{"rank", "index"}}, default"rank"—"rank"returns an array of feature indices ordered by importance and aligned withsklearn.feature_selection.SelectKBest;"index"returns the indices of the selected features with the most important one first
Returns¶
score:numpy array, shape(n_features,)— ranking score of every feature, aligned withsklearn.feature_selection.SelectKBest
References¶
- Original implementation from the DMML Lab@ASU Feature Selection Repository.