MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / SFS

Class SFS

JSAT/src/jsat/datatransform/featureselection/SFS.java:20–424  ·  view source on GitHub ↗

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. @author Edward Raff

Source from the content-addressed store, hash-verified

18 * @author Edward Raff
19 */
20public class SFS implements DataTransform
21{
22
23 private static final long serialVersionUID = 140187978708131002L;
24 private RemoveAttributeTransform finalTransform;
25 private Set<Integer> catSelected;
26 private Set<Integer> numSelected;
27 private double maxIncrease;
28 private Classifier classifier;
29 private Regressor regressor;
30 private int minFeatures, maxFeatures;
31 private int folds;
32 private Object evaluator;
33
34 /**
35 * Copy constructor
36 * @param toClone the SFS to copy
37 */
38 private SFS(SFS toClone)
39 {
40 if(toClone.catSelected != null)
41 {
42 this.finalTransform = toClone.finalTransform.clone();
43 this.catSelected = new IntSet(toClone.catSelected);
44 this.numSelected = new IntSet(toClone.numSelected);
45 }
46
47 this.maxIncrease = toClone.maxIncrease;
48 this.folds = toClone.folds;
49 this.minFeatures = toClone.minFeatures;
50 this.maxFeatures = toClone.maxFeatures;
51 this.evaluator = toClone.evaluator;
52 if (toClone.classifier != null)
53 this.classifier = toClone.classifier.clone();
54 if (toClone.regressor != null)
55 this.regressor = toClone.regressor.clone();
56 }
57
58 /**
59 * Performs SFS feature selection for a classification problem
60 *
61 * @param minFeatures the minimum number of features to find
62 * @param maxFeatures the maximum number of features to find
63 * @param evaluater the classifier to use in determining accuracy given a
64 * feature subset
65 * @param maxIncrease the maximum tolerable increase in error when a feature
66 * is added
67 */
68 public SFS(int minFeatures, int maxFeatures, Classifier evaluater, double maxIncrease)
69 {
70 this(minFeatures, maxFeatures, evaluater.clone(), 3, maxIncrease);
71 }
72
73 /**
74 * Performs SFS feature selection for a classification problem
75 *
76 * @param minFeatures the minimum number of features to find
77 * @param maxFeatures the maximum number of features to find

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected