jsat.datatransform.featureselection
Class LRS
- java.lang.Object
-
- jsat.datatransform.featureselection.LRS
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, DataTransform
public class LRS extends java.lang.Object implements DataTransform
plus-L minus-R Selection (LRS) is a greedy method of selecting a subset of features to use for prediction. Its behavior is dependent upon whether L or R is the larger value. No mater what, L features will be greedily added to the set to decrease the error rate, and R features will be greedily removed while trying to maintain the error rate.
If L > R, then L-R features will be selected, the L step running first followed by R performing pruning on the found set.
If L < R, then D-R+L features will be selected, where D is the original number of features. First R features will be removed, and then L of the removed features will be added back to the final set.
L = R is not allowed.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description LRS(int L, int R, ClassificationDataSet cds, Classifier evaluater, int folds)Performs LRS feature selection for a classification problemLRS(int L, int R, Classifier evaluater, int folds)Creates a LRS feature selection object for a classification problemLRS(int L, int R, RegressionDataSet rds, Regressor evaluater, int folds)Performs LRS feature selection for a regression problemLRS(int L, int R, Regressor evaluater, int folds)Creates a LRS feature selection object for a regression problem
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description LRSclone()voidfit(DataSet data)Fits this transform to the given dataset.intgetFeaturesToAdd()Returns the number of features to addintgetFeaturesToRemove()Returns the number of features to removeintgetFolds()java.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.voidsetFeaturesToAdd(int featuresToAdd)Sets the number of features to add (the L parameter).voidsetFeaturesToRemove(int featuresToRemove)Sets the number of features to remove (the R parameter).voidsetFolds(int folds)Sets the number of folds to use for cross validation when estimating the error rateDataPointtransform(DataPoint dp)Returns a new data point that is a transformation of the original data point.
-
-
-
Constructor Detail
-
LRS
public LRS(int L, int R, Classifier evaluater, int folds)Creates a LRS feature selection object for a classification problem- Parameters:
L- the number of features to greedily addR- the number of features to greedily removeevaluater- the classifier to use in determining accuracy given a feature subsetfolds- the number of cross validation folds to use in selection
-
LRS
public LRS(int L, int R, ClassificationDataSet cds, Classifier evaluater, int folds)Performs LRS feature selection for a classification problem- Parameters:
L- the number of features to greedily addR- the number of features to greedily removecds- 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 selection
-
LRS
public LRS(int L, int R, Regressor evaluater, int folds)Creates a LRS feature selection object for a regression problem- Parameters:
L- the number of features to greedily addR- the number of features to greedily removeevaluater- the regressor to use in determining accuracy given a feature subsetfolds- the number of cross validation folds to use in selection
-
LRS
public LRS(int L, int R, RegressionDataSet rds, Regressor evaluater, int folds)Performs LRS feature selection for a regression problem- Parameters:
L- the number of features to greedily addR- the number of features to greedily removerds- the data set to perform feature selection onevaluater- the regressor to use in determining accuracy given a feature subsetfolds- the number of cross validation folds to use in selection
-
-
Method Detail
-
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 LRS 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
-
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
-
setFeaturesToAdd
public void setFeaturesToAdd(int featuresToAdd)
Sets the number of features to add (the L parameter).- Parameters:
featuresToAdd- the number of features to greedily add
-
getFeaturesToAdd
public int getFeaturesToAdd()
Returns the number of features to add- Returns:
- the number of features to add
-
setFeaturesToRemove
public void setFeaturesToRemove(int featuresToRemove)
Sets the number of features to remove (the R parameter).- Parameters:
featuresToRemove- the number of features to greedily remove
-
getFeaturesToRemove
public int getFeaturesToRemove()
Returns the number of features to remove- Returns:
- the number of features to remove
-
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