m_Predictions = new ArrayList<Prediction>(); m_Predictions.add(new NumericPrediction(instance.classValue(), pred, instance.weight()));
m_Predictions = new ArrayList<Prediction>(); m_Predictions.add(new NumericPrediction(instance.classValue(), pred, instance.weight()));
/** * Store the prediction made by the classifier as a string. * * @param dist the distribution to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ @Override protected void doPrintClassification(double[] dist, Instance inst, int index) throws Exception { PredictionContainer cont; cont = new PredictionContainer(); cont.instance = inst; if (inst.classAttribute().isNominal()) cont.prediction = new NominalPrediction(inst.classValue(), dist, inst.weight()); else cont.prediction = new NumericPrediction(inst.classValue(), dist[0], inst.weight()); cont.attributeValues.putAll(attributeValuesToMap(inst)); m_Predictions.add(cont); }
/** * Store the prediction made by the classifier as a string. * * @param dist the distribution to use * @param inst the instance to generate text from * @param index the index in the dataset * @throws Exception if something goes wrong */ @Override protected void doPrintClassification(double[] dist, Instance inst, int index) throws Exception { PredictionContainer cont; cont = new PredictionContainer(); cont.instance = inst; if (inst.classAttribute().isNominal()) cont.prediction = new NominalPrediction(inst.classValue(), dist, inst.weight()); else cont.prediction = new NumericPrediction(inst.classValue(), dist[0], inst.weight()); cont.attributeValues.putAll(attributeValuesToMap(inst)); m_Predictions.add(cont); }
/** * Generate a single prediction for a test instance given the pre-trained * classifier. * * @param classifier the pre-trained Classifier to evaluate * @param test the test instance * @exception Exception if an error occurs */ public Prediction getPrediction(Classifier classifier, Instance test) throws Exception { double actual = test.classValue(); double[] dist = classifier.distributionForInstance(test); if (test.classAttribute().isNominal()) { return new NominalPrediction(actual, dist, test.weight()); } else { return new NumericPrediction(actual, dist[0], test.weight()); } }
/** * Generate a single prediction for a test instance given the pre-trained * classifier. * * @param classifier the pre-trained Classifier to evaluate * @param test the test instance * @exception Exception if an error occurs */ public Prediction getPrediction(Classifier classifier, Instance test) throws Exception { double actual = test.classValue(); double[] dist = classifier.distributionForInstance(test); if (test.classAttribute().isNominal()) { return new NominalPrediction(actual, dist, test.weight()); } else { return new NumericPrediction(actual, dist[0], test.weight()); } }