List of usage examples for weka.classifiers.trees RandomTree setSeed
@Override public void setSeed(int seed)
From source file:controller.MineroControler.java
public String clasificardorArbolAleat(String atributo) { BufferedReader breader = null; Instances datos = null;/*from ww w. j a v a 2s. c o m*/ breader = new BufferedReader(fuente_arff); try { datos = new Instances(breader); Attribute atr = datos.attribute(atributo); datos.setClass(atr); //datos.setClassIndex(0); } catch (IOException ex) { System.err.println("Problemas al intentar cargar los datos"); return null; } RandomTree arbol = new RandomTree(); // Class for constructing a tree that considers K randomly chosen attributes at each node. try { arbol.setNumFolds(100); arbol.setKValue(0); arbol.setMinNum(1); arbol.setMaxDepth(0); arbol.setSeed(1); arbol.buildClassifier(datos); } catch (Exception ex) { System.err.println("Problemas al ejecutar algorimo de clasificacion" + ex.getLocalizedMessage()); } return arbol.toString(); }
From source file:org.openml.webapplication.fantail.dc.landmarking.RandomTreeBasedLandmarker.java
License:Open Source License
public Map<String, Double> characterize(Instances data) { int numFolds = m_NumFolds; double score1 = 0.5; double score2 = 0.5; double score3 = 0.5; weka.classifiers.trees.RandomTree cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(m_Seed); cls.setMaxDepth(1);/* w ww. j av a 2s . co m*/ try { // ds.buildClassifier(data); weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score1 = eval.weightedAreaUnderROC(); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(m_Seed); cls.setMaxDepth(2); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score2 = eval.weightedAreaUnderROC(); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(m_Seed); cls.setMaxDepth(3); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score3 = eval.weightedAreaUnderROC(); } catch (Exception e) { e.printStackTrace(); } Map<String, Double> qualities = new HashMap<String, Double>(); qualities.put(ids[0], score1); qualities.put(ids[1], score2); qualities.put(ids[2], score3); return qualities; }
From source file:org.openml.webapplication.fantail.dc.landmarking.RandomTreeBasedLandmarker2.java
License:Open Source License
public Map<String, Double> characterize(Instances data) { int seed = m_Seed; Random r = new Random(seed); int numFolds = m_NumFolds; double score1 = 0.5; double score2 = 0.5; // double score3 = 0.5; double score3 = 0.5; double score4 = 0.5; // double score3 = 0.5; double score5 = 0.5; double score6 = 0.5; weka.classifiers.trees.RandomTree cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(r.nextInt()); cls.setKValue(m_K);//from ww w. j a v a 2 s . c om // cls.setMaxDepth(1); try { // ds.buildClassifier(data); weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score1 = eval.pctIncorrect(); score2 = eval.kappa(); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(r.nextInt()); cls.setKValue(m_K); // cls.setMaxDepth(2); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score3 = eval.pctIncorrect(); score4 = eval.kappa(); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(r.nextInt()); cls.setKValue(m_K); // cls.setMaxDepth(3); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); score5 = eval.pctIncorrect(); score6 = eval.kappa(); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(r.nextInt()); cls.setKValue(m_K); // cls.setMaxDepth(4); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); } catch (Exception e) { e.printStackTrace(); } // cls = new weka.classifiers.trees.RandomTree(); cls.setSeed(r.nextInt()); cls.setKValue(m_K); // cls.setMaxDepth(5); try { weka.classifiers.Evaluation eval = new weka.classifiers.Evaluation(data); eval.crossValidateModel(cls, data, numFolds, new java.util.Random(1)); } catch (Exception e) { e.printStackTrace(); } Map<String, Double> qualities = new HashMap<String, Double>(); qualities.put(ids[0], score1); qualities.put(ids[1], score2); qualities.put(ids[2], score3); qualities.put(ids[3], score4); qualities.put(ids[4], score5); qualities.put(ids[5], score6); return qualities; }