/** * Gets a human readable representation of this prediction. * * @return a human readable representation of this prediction. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("NUM: ").append(actual()).append(' ').append(predicted()); sb.append(' ').append(weight()); return sb.toString(); }
/** * Creates the NumericPrediction object. * * @param actual the actual value, or MISSING_VALUE. * @param predicted the predicted value, or MISSING_VALUE. * @param weight the weight assigned to the prediction. * @param predInt the prediction intervals from classifiers implementing * the <code>IntervalEstimator</code> interface. * @see IntervalEstimator */ public NumericPrediction(double actual, double predicted, double weight, double[][] predInt) { m_Actual = actual; m_Predicted = predicted; m_Weight = weight; setPredictionIntervals(predInt); }
m_Predictions = new ArrayList<Prediction>(); m_Predictions.add(new NumericPrediction(instance.classValue(), pred, instance.weight()));
preds = m_Evaluation.predictions(); for (i = 0; i < preds.size(); i++) { num = ((NumericPrediction) preds.get(i)).predictionIntervals().length; if (num > maxNum) { maxNum = num; .arraycopy(inst.toDoubleArray(), 0, values, 0, inst.numAttributes()); predInt = ((NumericPrediction) preds.get(i)).predictionIntervals(); for (n = 0; n < maxNum; n++) { if (n < predInt.length) {
m_Predictions = new ArrayList<Prediction>(); m_Predictions.add(new NumericPrediction(instance.classValue(), pred, instance.weight()));
preds = m_Evaluation.predictions(); for (i = 0; i < preds.size(); i++) { num = ((NumericPrediction) preds.get(i)).predictionIntervals().length; if (num > maxNum) { maxNum = num; .arraycopy(inst.toDoubleArray(), 0, values, 0, inst.numAttributes()); predInt = ((NumericPrediction) preds.get(i)).predictionIntervals(); for (n = 0; n < maxNum; n++) { if (n < predInt.length) {
/** * Gets a human readable representation of this prediction. * * @return a human readable representation of this prediction. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("NUM: ").append(actual()).append(' ').append(predicted()); sb.append(' ').append(weight()); return sb.toString(); }
/** * 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); }
/** * Creates the NumericPrediction object. * * @param actual the actual value, or MISSING_VALUE. * @param predicted the predicted value, or MISSING_VALUE. * @param weight the weight assigned to the prediction. * @param predInt the prediction intervals from classifiers implementing * the <code>IntervalEstimator</code> interface. * @see IntervalEstimator */ public NumericPrediction(double actual, double predicted, double weight, double[][] predInt) { m_Actual = actual; m_Predicted = predicted; m_Weight = weight; setPredictionIntervals(predInt); }
/** * 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); }
if (m_Predictions != null) { ((NumericPrediction) m_Predictions.get(m_Predictions.size() - 1)) .setPredictionIntervals(preds);
/** * 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()); } }
if (m_Predictions != null) { ((NumericPrediction) m_Predictions.get(m_Predictions.size() - 1)) .setPredictionIntervals(preds);
/** * 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()); } }