mlpy_wrapper_nodes¶
Module: missions.nodes.feature_selection.mlpy_wrapper_nodes
¶
Use feature selection methods implemented in MLPY
Inheritance diagram for pySPACE.missions.nodes.feature_selection.mlpy_wrapper_nodes
:
MLPYFeatureSelectionWrapper
¶
-
class
pySPACE.missions.nodes.feature_selection.mlpy_wrapper_nodes.
MLPYFeatureSelectionWrapper
(num_retained_features=None, ranking_method=None, weighting_method=None, selected_features_path=None, **kwargs)[source]¶ Bases:
pySPACE.missions.nodes.base_node.BaseNode
Wrapper node that allows to use MLPY algorithms
This module contains a node that wraps the feature selection algorithms contained in the MLPY package (https://mlpy.fbk.eu/)
MLPY provides several feature weighting methods that are wrappers around classifier, e.g.:
- Support Vector Machines (SVMs)
- Spectral Regression Discriminant Analysis (SRDA)
- Fisher Discriminant Analysis (FDA)
- Penalized Discriminant Analysis (PDA)
- Diagonal Linear Discriminant Analysis (DLDA)
Furthermore, MLPY has also some filter-like feature weighting methods:
- Iterative Relief (I-RELIEF)
- Discrete Wavelet Transform (DWT)
Based on these feature weighting algorithms, the ranking method contained in MLPY can be used to create a ranking of the utility of different features. The following ranking algorithms can be used by MLPY:
- Recursive Feature Elimination (rfe, onerfe, erfe, bisrfe, sqrtrfe)
- Recursive Forward Selection (rfs)
The wrapper node expects as argument
- how many of the features it should retain
- which feature weighting method it should use
- which feature ranking method it should use
Parameters
num_retained_features: The number of features that should be retained by the node. This information must be specified if selected_features_path is not specified.
(optional, default: None)
ranking_method: A string that specifies the feature elimination method used internally by MLPY’s feature ranking method. Can be ‘rfe’, ‘onerfe’, ‘erfe’, ‘bisrfe’, ‘sqrtrfe’, or ‘rfs’
(optional, default: None)
weighting_method: An object instance that provides an weights(x,y) method that takes as input:
- x : training data (#sample x #feature) 2D numpy array float
- y : classes (two classes, -1 and 1)
and returns a float in [0,1]. This float is the weight of the respective feature. A set of classes that can be used are contained in MLPY, for instance mlpy.svm.
(optional, default: None)
selected_features_path: An absolute path from which the selected features are loaded. If not specified, these features are learned from the training data. In this case, num_retained_features must be specified.
(optional, default: None)
Exemplary Call
- node : RandomFeatureSelection parameters : num_retained_features : 100 ranking_method : "bisrfe" weighting_method: "eval(__import__('mlpy').svm)"
Author: Jan Hendrik Metzen (jhm@informatik.uni-bremen.de) Created: 2009/02/03 Class Components Summary
_execute
(feature_vector)Projects the feature vector features onto the subspace of features _stop_training
([debug])Called automatically at the end of training _train
(data, label)Add the given data point along with its class label is_supervised
()Returns whether this node requires supervised training is_trainable
()Returns whether this node is trainable store_state
(result_dir[, index])Stores this node in the given directory result_dir -
__init__
(num_retained_features=None, ranking_method=None, weighting_method=None, selected_features_path=None, **kwargs)[source]¶
-
_train
(data, label)[source]¶ Add the given data point along with its class label to the training set
-
_stop_training
(debug=False)[source]¶ Called automatically at the end of training
Computes a ranking of features and stores a list of the indices of those feature that should be retained