List of usage examples for weka.attributeSelection ChiSquaredAttributeEval ChiSquaredAttributeEval
public ChiSquaredAttributeEval()
From source file:trabfs.machineLeaningFrameWork.core.Problema.java
public double[] getAttributeQuality() { try {/* w w w . j av a2s. c om*/ ASEvaluation[] filters = { new InfoGainAttributeEval(), new ChiSquaredAttributeEval(), new ReliefFAttributeEval() }; R = new double[data.numAttributes() - 1][filters.length]; Ranker rk = new Ranker(); AttributeSelection selec = new AttributeSelection(); selec.setSearch(rk); for (int j = 0; j < filters.length; j++) { selec.setEvaluator(filters[j]); selec.SelectAttributes(data); double[][] full = selec.rankedAttributes(); //double[] r = new double[full.length]; Arrays.sort(full, new Comparator() { @Override public int compare(Object t, Object t1) { double[] a1 = (double[]) t; double[] a2 = (double[]) t1; if (a1[0] > a2[0]) return 1; else if (a1[0] < a2[0]) return -1; else return 0; } }); double max = Double.NEGATIVE_INFINITY, min = Double.POSITIVE_INFINITY; for (int i = 0; i < full.length; i++) { if (full[i][1] < min) min = full[i][1]; if (full[i][1] > max) max = full[i][1]; } // armazena for (int i = 0; i < full.length; i++) { R[i][j] = (full[i][1] - min) / (max - min); } } double[] Rfinal = new double[data.numAttributes() - 1]; double SW = 1.0f; for (int i = 0; i < Rfinal.length; i++) { Rfinal[i] = somaWK(i) / 3.0f; } return Rfinal; } catch (Exception ex) { Logger.getLogger(Problema.class.getName()).log(Level.SEVERE, null, ex); } return null; }