Package weka.classifiers.evaluation

Examples of weka.classifiers.evaluation.NumericPrediction


      pred = dist[0];
      updateStatsForPredictor(pred, instance);
      if (storePredictions) {
        if (m_Predictions == null)
          m_Predictions = new FastVector();
        m_Predictions.addElement(new NumericPrediction(instance.classValue(), pred,
                                                       instance.weight()));
      }
    }

    return pred;
View Full Code Here


        // look up this requested target in the list that the forecaster
        // has predicted
        int predIndex = forecasterTargets.indexOf(targetName.trim());
        if (predIndex >= 0) {
          NumericPrediction predsForTargetAtStepJ = predsForStepJ
              .get(predIndex);
          XYIntervalSeries predSeries = null;
          int datasetIndex = xyDataset.indexOf(targetName + "-predicted");
          predSeries = xyDataset.getSeries(datasetIndex);

          if (predSeries != null) {
            double y = predsForTargetAtStepJ.predicted();
            double x = Utils.missingValue();
            double yHigh = y;
            double yLow = y;
            double[][] conf = predsForTargetAtStepJ.predictionIntervals();
            if (conf.length > 0) {
              yLow = conf[0][0];
              yHigh = conf[0][1];
              hasConfidenceIntervals = true;
            }
View Full Code Here

      temp.append(pad("conf", " ", maxConfWidth, true) + "  ");
    }
    temp.append(pad("error", " ", maxColWidth, true) + "\n");

    for (int i = 0; i < preds.size(); i++) {
      NumericPrediction pred = preds.get(i);
      String instNum = pad("" + (instanceNumberOffset + i + stepAhead), " ",
          maxColWidth, true);
      temp.append(instNum + "  ");

      double actual = pred.actual();
      String actualS = null;
      if (Utils.isMissingValue(actual)) {
        actualS = pad("?", " ", maxColWidth, true);
      } else {
        actualS = Utils.doubleToString(actual, 4);
        actualS = pad(actualS, " ", maxColWidth, true);
      }
      temp.append(actualS + "  ");

      double predicted = pred.predicted();
      String predictedS = null;
      if (Utils.isMissingValue(predicted)) {
        predictedS = pad("?", " ", maxColWidth, true);
      } else {
        predictedS = Utils.doubleToString(predicted, 4);
        predictedS = pad(predictedS, " ", maxColWidth, true);
      }
      temp.append(predictedS + "  ");

      if (hasConfidenceIntervals) {
        double[][] limits = pred.predictionIntervals();
        double low = limits[0][0];
        double high = limits[0][1];
        String limitsS = Utils.doubleToString(low, 3) + ":"
            + Utils.doubleToString(high, 3);
        limitsS = pad(limitsS, " ", maxConfWidth, true);
        temp.append(limitsS).append("  ");
      }

      double error = pred.error();
      String errorS = null;
      if (Utils.isMissingValue(error)) {
        errorS = pad("?", " ", maxColWidth, true);
      } else {
        errorS = Utils.doubleToString(error, 4);
View Full Code Here

      NumericPrediction forecast, double actualValue) {
   
    double predictedValue = forecast.predicted();
    double[][] intervals = forecast.predictionIntervals();
   
    NumericPrediction pred = new NumericPrediction(actualValue, predictedValue, 1,
        intervals);
    m_predictions.get(targetIndex).add(pred);
    m_counts[targetIndex]++;
  }
View Full Code Here

      double actualValue = getTargetValue(m_targetFieldNames.get(i), inst);
      double predictedValue = forecasts.get(i).predicted();
      //System.err.println("Actual: " + actualValue + " Predicted: " + predictedValue);
      double[][] intervals = forecasts.get(i).predictionIntervals();
     
      NumericPrediction pred = new NumericPrediction(actualValue, predictedValue, 1, intervals);
      m_predictions.get(i).add(pred);
     
      if (!Utils.isMissingValue(predictedValue) &&
          !Utils.isMissingValue(actualValue)) {
        m_counts[i]++;
View Full Code Here

      NumericPrediction forecast, double actualValue) {
   
    double predictedValue = forecast.predicted();
    double[][] intervals = forecast.predictionIntervals();
   
    NumericPrediction pred = new NumericPrediction(actualValue, predictedValue, 1,
        intervals);
    m_predictions.get(targetIndex).add(pred);
    m_counts[targetIndex]++;
  }
View Full Code Here

      Instance inst) throws Exception {
    super.evaluateForInstance(forecasts, inst);
   
    if (m_predictions.get(0).size() > 1) {
      for (int i = 0; i < m_targetFieldNames.size(); i++) {
        NumericPrediction currentForI =
          m_predictions.get(i).get(m_predictions.get(i).size() - 1);
        NumericPrediction previousForI =
          m_predictions.get(i).get(m_predictions.get(i).size() - 2);
       
        if (!Utils.isMissingValue(currentForI.predicted()) &&
            !Utils.isMissingValue(previousForI.predicted()) &&
            !Utils.isMissingValue(currentForI.actual()) &&
            !Utils.isMissingValue(previousForI.actual())) {
          double predictedDirection =
            currentForI.predicted() - previousForI.predicted();
          double actualDirection =
            currentForI.actual() - previousForI.actual();
         
          if (actualDirection > 0 && predictedDirection > 0) {
            m_correct[i]++;           
          } else if (actualDirection < 0 && predictedDirection < 0) {
            m_correct[i]++;
View Full Code Here

          double[] limits = m_confidenceLimitEstimator
              .getConfidenceLimitsForTarget(m_fieldsToForecast.get(j),
                  preds[j], i + 1);
          double[][] limitsToAdd = new double[1][];
          limitsToAdd[0] = limits;
          finalForecast.add(new NumericPrediction(Utils.missingValue(),
              preds[j], 1.0, limitsToAdd));
        } else {
          finalForecast.add(new NumericPrediction(Utils.missingValue(),
              preds[j]));
        }
      }
      forecastForSteps.add(finalForecast);
View Full Code Here

      }

      for (int j = 0; j < m_fieldsToForecast.size(); j++) {
        String target = m_fieldsToForecast.get(j);
        int targetI = m_outgoingStructure.attribute(target).index();
        NumericPrediction predForTargetAtStep = predsForStep.get(j);
        double y = predForTargetAtStep.predicted();
        double yHigh = y;
        double yLow = y;
        double[][] conf = predForTargetAtStep.predictionIntervals();
        if (!Utils.isMissingValue(y)) {
          outVals[targetI] = y;
        }

        // any confidence bounds?
View Full Code Here

       Date startdate=fmt.parse(maxThedate);
       String[] numfieldsarr=numberfield.toString().split(",");
        for (int i = 0; i < presize; i++) {
          List<NumericPrediction> predsAtStep = forecast.get(i);
          for (int j = 0; j < numfieldsarr.length; j++) {
            NumericPrediction predForTarget = predsAtStep.get(j);
       
            if(lines.containsKey(numfieldsarr[j]+"_pre"))
           {
             ArrayList<ArrayList<Object>> d=(ArrayList<ArrayList<Object>>) lines.get(numfieldsarr[j]+"_pre").get("data");
             ArrayList<Object> drow=new ArrayList<Object>();
            
             long t=new Date(startdate.getTime()+1000l*3600*24*(i)).getTime();
             minmax.min=Math.min(minmax.min, t);
             minmax.max=Math.max(minmax.max, t);
             drow.add(0, t);
             drow.add(0, t);
             drow.add(1, predForTarget.predicted());
             d.add(drow);
           }
          }
        }
  }
View Full Code Here

TOP

Related Classes of weka.classifiers.evaluation.NumericPrediction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.