jsat.datatransform.featureselection
Class SFS
- java.lang.Object
-
- jsat.datatransform.featureselection.SFS
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform
public class SFS extends java.lang.Object implements DataTransform
Sequential Forward Selection (SFS) is a greedy method of selecting a subset of features to use for prediction. It starts from the set of no features and attempts to add the next best feature to the set at each iteration.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description SFS(int minFeatures, int maxFeatures, ClassificationDataSet dataSet, Classifier evaluater, int folds, double maxIncrease)Performs SFS feature selection for a classification problemSFS(int minFeatures, int maxFeatures, Classifier evaluater, double maxIncrease)Performs SFS feature selection for a classification problemSFS(int minFeatures, int maxFeatures, RegressionDataSet dataSet, Regressor regressor, int folds, double maxIncrease)Performs SFS feature selection for a regression problemSFS(int minFeatures, int maxFeatures, Regressor regressor, double maxIncrease)Creates SFS feature selection for a regression problem
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description SFSclone()voidfit(DataSet data)Fits this transform to the given dataset.intgetFolds()intgetMaxFeatures()Returns the maximum number of features to finddoublegetMaxIncrease()intgetMinFeatures()Returns the minimum number of features to findjava.util.Set<java.lang.Integer>getSelectedCategorical()Returns a copy of the set of categorical features selected by the search algorithmjava.util.Set<java.lang.Integer>getSelectedNumerical()Returns a copy of the set of numerical features selected by the search algorithm.voidsetFolds(int folds)Sets the number of folds to use for cross validation when estimating the error ratevoidsetMaxFeatures(int maxFeatures)Sets the maximum number of features that must be selectedvoidsetMaxIncrease(double maxIncrease)Sets the maximum allowable the maximum tolerable increase in error when a feature is addedvoidsetMinFeatures(int minFeatures)Sets the minimum number of features that must be selectedDataPointtransform(DataPoint dp)Returns a new data point that is a transformation of the original data point.
-
-
-
Constructor Detail
-
SFS
public SFS(int minFeatures, int maxFeatures, Classifier evaluater, double maxIncrease)Performs SFS feature selection for a classification problem- Parameters:
minFeatures- the minimum number of features to findmaxFeatures- the maximum number of features to findevaluater- the classifier to use in determining accuracy given a feature subsetmaxIncrease- the maximum tolerable increase in error when a feature is added
-
SFS
public SFS(int minFeatures, int maxFeatures, ClassificationDataSet dataSet, Classifier evaluater, int folds, double maxIncrease)Performs SFS feature selection for a classification problem- Parameters:
minFeatures- the minimum number of features to findmaxFeatures- the maximum number of features to finddataSet- the data set to perform feature selection onevaluater- the classifier to use in determining accuracy given a feature subsetfolds- the number of cross validation folds to use in selectionmaxIncrease- the maximum tolerable increase in error when a feature is added
-
SFS
public SFS(int minFeatures, int maxFeatures, Regressor regressor, double maxIncrease)Creates SFS feature selection for a regression problem- Parameters:
minFeatures- the minimum number of features to findmaxFeatures- the maximum number of features to findregressor- the regressor to use in determining accuracy given a feature subsetmaxIncrease- the maximum tolerable increase in error when a feature is added
-
SFS
public SFS(int minFeatures, int maxFeatures, RegressionDataSet dataSet, Regressor regressor, int folds, double maxIncrease)Performs SFS feature selection for a regression problem- Parameters:
minFeatures- the minimum number of features to findmaxFeatures- the maximum number of features to finddataSet- the data set to perform feature selection onregressor- the regressor to use in determining accuracy given a feature subsetfolds- the number of cross validation folds to use in selectionmaxIncrease- the maximum tolerable increase in error when a feature is added
-
-
Method Detail
-
fit
public void fit(DataSet data)
Description copied from interface:DataTransformFits this transform to the given dataset. Some transforms can only be learned from classification or regression datasets. If an incompatible dataset type is given, aFailedToFitExceptionexception may be thrown.- Specified by:
fitin interfaceDataTransform- Parameters:
data- the dataset to fir this transform to
-
transform
public DataPoint transform(DataPoint dp)
Description copied from interface:DataTransformReturns a new data point that is a transformation of the original data point. This new data point is a different object, but may contain the same references as the original data point. It is not guaranteed that you can mutate the transformed point without having a side effect on the original point.- Specified by:
transformin interfaceDataTransform- Parameters:
dp- the data point to apply a transformation to- Returns:
- a transformed data point
-
clone
public SFS clone()
- Specified by:
clonein interfaceDataTransform- Overrides:
clonein classjava.lang.Object
-
getSelectedCategorical
public java.util.Set<java.lang.Integer> getSelectedCategorical()
Returns a copy of the set of categorical features selected by the search algorithm- Returns:
- the set of categorical features to use
-
getSelectedNumerical
public java.util.Set<java.lang.Integer> getSelectedNumerical()
Returns a copy of the set of numerical features selected by the search algorithm.- Returns:
- the set of numeric features to use
-
setMaxIncrease
public void setMaxIncrease(double maxIncrease)
Sets the maximum allowable the maximum tolerable increase in error when a feature is added- Parameters:
maxIncrease- the maximum allowable the maximum tolerable increase in error when a feature is added
-
getMaxIncrease
public double getMaxIncrease()
- Returns:
- the maximum allowable the maximum tolerable increase in error when a feature is added
-
setMinFeatures
public void setMinFeatures(int minFeatures)
Sets the minimum number of features that must be selected- Parameters:
minFeatures- the minimum number of features to learn
-
getMinFeatures
public int getMinFeatures()
Returns the minimum number of features to find- Returns:
- the minimum number of features to find
-
setMaxFeatures
public void setMaxFeatures(int maxFeatures)
Sets the maximum number of features that must be selected- Parameters:
maxFeatures- the maximum number of features to find
-
getMaxFeatures
public int getMaxFeatures()
Returns the maximum number of features to find- Returns:
- the maximum number of features to find
-
setFolds
public void setFolds(int folds)
Sets the number of folds to use for cross validation when estimating the error rate- Parameters:
folds- the number of folds to use for cross validation when estimating the error rate
-
getFolds
public int getFolds()
- Returns:
- the number of folds to use for cross validation when estimating the error rate
-
-
DataMelt 3.0 © DataMelt by jWork.ORG