List of usage examples for weka.attributeSelection CfsSubsetEval evaluateSubset
@Override public double evaluateSubset(BitSet subset) throws Exception
From source file:com.rapidminer.operator.validation.CFSFeatureSetEvaluator.java
License:Open Source License
public IOObject[] apply() throws OperatorException { ExampleSet exampleSet = getInput(ExampleSet.class); Instances instances = WekaTools.toWekaInstances(exampleSet, "TempInstances", WekaInstancesAdaptor.LEARNING); double performance = 0.0d; try {/* w w w.j a v a 2 s . c o m*/ CfsSubsetEval evaluator = new CfsSubsetEval(); evaluator.buildEvaluator(instances); BitSet bitSet = new BitSet(exampleSet.getAttributes().size()); bitSet.flip(0, exampleSet.getAttributes().size()); performance = evaluator.evaluateSubset(bitSet); } catch (Exception e) { throw new UserError(this, e, 905, new Object[] { "CfsSubsetEval", e.getMessage() }); } PerformanceVector result = new PerformanceVector(); result.addCriterion(new EstimatedPerformance("CorrelationFS", performance, 1, false)); return new IOObject[] { result }; }
From source file:sirius.misc.featurevisualizer.FeatureVisualizerPane.java
License:Open Source License
private void setTop2CFSIndex() { if (top1CFSIndex != -1) return;//from w w w .j a v a 2s . c o m Thread runThread = new Thread() { public void run() { try { CfsSubsetEval myCfs = new CfsSubsetEval(); myCfs.buildEvaluator(instances); double maxCFSScore = -9999999; int divisor = instances.numAttributes() / 100; BitSet bs = new BitSet(); //-1 because assume that last attribute is class attribute for (int x = 0; x < instances.numAttributes() - 1; x++) { if (divisor != 0 && x % divisor == 0) statusTextField.setText( "Calculating Top CFS.. " + ((x * 100) / instances.numAttributes()) + "%"); bs.set(x, true); //-1 because assume that last attribute is class attribute for (int y = (x + 1); y < instances.numAttributes() - 1; y++) { bs.set(y, true); if (myCfs.evaluateSubset(bs) > maxCFSScore) { maxCFSScore = myCfs.evaluateSubset(bs); top1CFSIndex = x; top2CFSIndex = y; } bs.set(y, false); } bs.set(x, false); } statusTextField.setText("Done"); setTop2CFS(); } catch (Exception e) { JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); e.printStackTrace(); } } }; runThread.setPriority(Thread.MIN_PRIORITY); runThread.start(); }