ITMO_FS.filters.multivariate.TraceRatioFisher

class ITMO_FS.filters.multivariate.TraceRatioFisher(n_selected_features)

Creates TraceRatio(similarity based) feature selection filter performed in supervised way, i.e fisher version

Parameters:n_selected_features (int) – Amount of features to filter

Notes

For more details see this paper.

Examples

>>> from ITMO_FS.filters.multivariate import TraceRatioFisher
>>> X = np.array([[1, 2, 3, 3, 1],[2, 2, 3, 3, 2], [1, 3, 3, 1, 3],[3, 1, 3, 1, 4],[4, 4, 3, 1, 5]], dtype = np.integer)
>>> y = np.array([1, 2, 3, 4, 5], dtype=np.integer)
>>> tracer = TraceRatioFisher(3)
>>> tracer.fit_transform(X, y)
array([[1, 1, 2],
       [2, 2, 2],
       [3, 1, 3],
       [4, 3, 1],
       [5, 4, 4]])
__init__(n_selected_features)

Initialize self. See help(type(self)) for accurate signature.

fit(X, y, feature_names=None)

Fits filter

Parameters:
  • X (numpy array, shape (n_samples, n_features)) – The training input samples
  • y (numpy array, shape (n_samples, )) – The target values
  • feature_names (list of strings, optional) – In case you want to define feature names
Returns:

Return type:

None

Examples

fit_transform(X, y, feature_names=None)

Fits the filter and transforms given dataset X.

Parameters:
  • X (array-like, shape (n_features, n_samples)) – The training input samples.
  • y (array-like, shape (n_samples, )) – The target values.
  • feature_names (list of strings, optional) – In case you want to define feature names
Returns:

Return type:

X dataset sliced with features selected by the filter

transform(X)

Transform given data by slicing it with selected features.

Parameters:X (array-like, shape (n_samples, n_features)) – The training input samples.
Returns:
Return type:Transformed 2D numpy array