List of usage examples for weka.classifiers.misc SerializedClassifier getCurrentModel
public Classifier getCurrentModel()
From source file:clasificador.RedNeuronal.java
public void testing() { try {//from ww w . jav a 2 s . co m FileReader testReader = new FileReader( new File(System.getProperty("user.dir") + "\\src\\clasificador\\archivos\\librotest.arff")); Instances testInstance = new Instances(testReader); testInstance.setClassIndex(testInstance.numAttributes() - 1); Evaluation evalTest = new Evaluation(testInstance); SerializedClassifier clasificador = new SerializedClassifier(); clasificador.setModelFile(new File("TrainMLP.train")); //CLASIFICADOR ESTANDAR Classifier clasificadorEstandar = clasificador.getCurrentModel(); evalTest.evaluateModel(clasificadorEstandar, testInstance); System.out.println(evalTest.toSummaryString("resultado:", false)); System.out.println(evalTest.toMatrixString("*****************Matriz de confusion*******")); //vamos a predecir el numero q voy a usar // evalTest.toMatrixString(); } catch (IOException e) { e.printStackTrace(); } catch (Exception ex) { Logger.getLogger(RedNeuronal.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:clasificador.RedNeuronal.java
public void prediccion() { FileReader testReader = null; try {/*from w w w.j av a2 s.co m*/ testReader = new FileReader( new File(System.getProperty("user.dir") + "\\src\\clasificador\\archivos\\libro1.arff")); Instances testInstance = new Instances(testReader); testInstance.setClassIndex(testInstance.numAttributes() - 1); Evaluation evalTest = new Evaluation(testInstance); SerializedClassifier clasificador = new SerializedClassifier(); clasificador.setModelFile(new File("TrainMLP.train")); //CLASIFICADOR ESTANDAR Classifier clasificadorEstandar = clasificador.getCurrentModel(); evalTest.evaluateModel(clasificadorEstandar, testInstance); double[] valores = evalTest.evaluateModel(clasificadorEstandar, testInstance); for (int i = 0; i < valores.length; i++) { System.out.println("se predice: " + valores[i] + "\n"); } } catch (FileNotFoundException ex) { Logger.getLogger(RedNeuronal.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(RedNeuronal.class.getName()).log(Level.SEVERE, null, ex); } catch (Exception ex) { Logger.getLogger(RedNeuronal.class.getName()).log(Level.SEVERE, null, ex); } finally { try { testReader.close(); } catch (IOException ex) { Logger.getLogger(RedNeuronal.class.getName()).log(Level.SEVERE, null, ex); } } }