weka.attributeSelection.CfsSubsetEval Java Examples

The following examples show how to use weka.attributeSelection.CfsSubsetEval. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttribSelect.java    From Hands-On-Artificial-Intelligence-with-Java-for-Beginners with MIT License 6 votes vote down vote up
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    // TODO code application logic here
    try {
          DataSource src = new DataSource("/Users/admin/Documents/NetBeansProjects/Datasets/weather.arff");
          Instances dt = src.getDataSet();
          
          AttributeSelection asel = new AttributeSelection();
          
          CfsSubsetEval evl = new CfsSubsetEval();
          GreedyStepwise sh = new GreedyStepwise();
          
          asel.setEvaluator(evl);
          asel.setSearch(sh);
          asel.setInputFormat(dt);
          
          Instances nd = Filter.useFilter(dt, asel);
          ArffSaver as = new ArffSaver();
          as.setInstances(nd);
          as.setFile(new File("weather-sel.arff"));
          as.writeBatch();
    }
    catch(Exception e){
        System.out.println(e.getMessage());
    }
}
 
Example #2
Source File: AttributeSelection.java    From tsml with GNU General Public License v3.0 5 votes vote down vote up
/**
 * set options to their default values
 */
protected void resetOptions() {

  m_trainSelector = new weka.attributeSelection.AttributeSelection();
  setEvaluator(new CfsSubsetEval());
  setSearch(new BestFirst());
  m_SelectedAttributes = null;
  m_FilterOptions = null;
}
 
Example #3
Source File: WekaFeatureSelectionTest.java    From Java-Data-Science-Cookbook with MIT License 5 votes vote down vote up
public void selectFeatures(){
	AttributeSelection attSelection = new AttributeSelection();
    CfsSubsetEval eval = new CfsSubsetEval();
    BestFirst search = new BestFirst();
    attSelection.setEvaluator(eval);
    attSelection.setSearch(search);
    try {
		attSelection.SelectAttributes(iris);
		int[] attIndex = attSelection.selectedAttributes();
		System.out.println(Utils.arrayToString(attIndex));
	} catch (Exception e) {
	}
}
 
Example #4
Source File: WekaFeatureSelectionTest.java    From Java-Data-Science-Cookbook with MIT License 5 votes vote down vote up
public void selectFeaturesWithFilter(){
	weka.filters.supervised.attribute.AttributeSelection filter = new weka.filters.supervised.attribute.AttributeSelection();
    CfsSubsetEval eval = new CfsSubsetEval();
    BestFirst search = new BestFirst();
    filter.setEvaluator(eval);
    filter.setSearch(search);
    try {
		filter.setInputFormat(iris);
		Instances newData = Filter.useFilter(iris, filter);
		System.out.println(newData);
	} catch (Exception e) {
	}
}