Package weka.core

Examples of weka.core.DenseInstance


    vals[j] = dataSet.attribute(j).addStringValue("" + cval);
  } else {
    vals[j] = ((Double)cval).doubleValue();
  }
      }
      dataSet.add(new DenseInstance(1.0, vals));
    }
    m_structure = new Instances(dataSet, 0);
    setRetrieval(BATCH);
    m_cumulativeStructure = null; // conserve memory
   
View Full Code Here


        vals[0] = current.value(10); // sample size
        vals[1] = (current.value(0) * tpCost
            + current.value(1) * fnCost
            + current.value(2) * fpCost
            + current.value(3) * tnCost) * scaleFactor;
        Instance newInst = new DenseInstance(1.0, vals);
        costBenefitI.add(newInst);
      }
     
      costBenefitI.compactify();
     
View Full Code Here

  System.err.println("Error parsing value #" + (index+1) + ": " + e.toString());
  return null;
      }
    }

    result = new DenseInstance(weight, vals);
    result.setDataset(data);
     
    return result;
  }
View Full Code Here

    double[] newVals = new double[numAtts];
    for (int i = 0; i < newVals.length; i++) {
      newVals[i] = weka.core.Utils.missingValue();
    }
    newVals[timeIndex] = incrTime;
    Instance newInst = new DenseInstance(1.0, newVals);

    /*
     * if (missingReport != null) { if (periodicityHandler.isDateBased()) {
     * String timeFormat = "yyyy-MM-dd'T'HH:mm:ss"; SimpleDateFormat sdf = new
     * SimpleDateFormat(); sdf.applyPattern(timeFormat); Date d = new
View Full Code Here

      double targetValue = insts.instance(i).value(targetIndex);
      double time = i;
      double[] vals = new double[2];
      vals[0] = time;
      vals[1] = targetValue;
      DenseInstance d = new DenseInstance(1.0, vals);
      simple.add(d);
    }

    simple.setClassIndex(1);
    lagFiller.buildClassifier(simple);
View Full Code Here

    if (setAnyPeriodic) {
      setPeriodicValues(result);
    }

    m_lastHistoricInstance = new DenseInstance(result);
    m_lastHistoricInstance.setDataset(result.dataset());

    if (m_extraneousAttributeRemover != null) {
      m_extraneousAttributeRemover.input(result);
      result = m_extraneousAttributeRemover.output();
View Full Code Here

    } else {
    vals[count++] = tc.getTruePositive() / expectedByChance;
    
    }
    vals[count++] = prob;
    return new DenseInstance(1.0, vals);
  }
View Full Code Here

    }
    Instance inst = null;
    if (dest instanceof SparseInstance) {
      inst = new SparseInstance(dest.weight(), vals);
    } else {
      inst = new DenseInstance(dest.weight(), vals);
    }
    inst.setDataset(dest.dataset());
    return inst;
  }
View Full Code Here

          }
        }
      }

      // create the test instance (original format)
      Instance origTest = new DenseInstance(1.0, newVals);
      origTest.setDataset(m_originalHeader);

      // System.err.println("Original with periodic set " + origTest);

      Instance transformedWithDate = origTest;

      // do all the filters
      // System.err.println("--- " + transformedWithDate);

      // transformedWithDate = applyFilters(transformedWithDate, true, true);
      transformedWithDate = m_lagMaker.processInstancePreview(
          transformedWithDate, incrementTime, setPeriodics);

      // the date time stamp (if exists) has now been remapped, so we can remove
      // the original
      m_dateRemover.input(transformedWithDate);
      Instance transformed = m_dateRemover.output();

      // System.err.println(transformedWithDate.dataset());
      // System.err.println(transformedWithDate);

      // System.err.println("Transformed: " + transformed);

      // get a prediction
      double[] preds = new double[m_singleTargetForecasters.size()];
      for (int j = 0; j < m_singleTargetForecasters.size(); j++) {
        preds[j] = m_singleTargetForecasters.get(j).forecastOneStepAhead(
            transformed);
      }

      // predictions at step i for all the targets (can only handle a single
      // target at
      // present)
      List<NumericPrediction> finalForecast = new ArrayList<NumericPrediction>();

      // add confidence limits (if applicable)
      for (int j = 0; j < m_fieldsToForecast.size(); j++) {
        if (m_confidenceLimitEstimator != null
            && i < m_calculateConfLimitsSteps) {
          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);

      // set the value of the target in the original test instance
      for (int j = 0; j < m_fieldsToForecast.size(); j++) {
        int targetIndex = m_originalHeader.attribute(m_fieldsToForecast.get(j))
            .index();
        origTest.setValue(targetIndex, preds[j]);
      }

      // If we have a real time stamp, then set the incremented value in the
      // original
      // test instance (doesn't really need to be done if we've read a
      // non-missing
      // time value out of any supplied overlay data)
      if (!m_lagMaker.isUsingAnArtificialTimeIndex()
          && m_lagMaker.getAdjustForTrends()
          && m_lagMaker.getTimeStampField() != null
          && m_lagMaker.getTimeStampField().length() > 0) {
        int timeIndex = m_originalHeader.attribute(
            m_lagMaker.getTimeStampField()).index();
        double timeValue = transformedWithDate.value(transformedWithDate
            .dataset().attribute(m_lagMaker.getTimeStampField()));
        origTest.setValue(timeIndex, timeValue);
      }

      // now re-prime the forecaster. Incremental method will never buffer here
      // because we never have missing targets, since we've just forecasted
      // them!
View Full Code Here

              target + "_upperBound").index();
          outVals[indexOfLow] = yLow;
          outVals[indexOfHigh] = yHigh;
        }
      }
      outputI = new DenseInstance(1.0, outVals);
      outputI.setDataset(m_outgoingStructure);

      // notify listeners of output instance
      InstanceEvent ie = new InstanceEvent(this, outputI,
          InstanceEvent.INSTANCE_AVAILABLE);
View Full Code Here

TOP

Related Classes of weka.core.DenseInstance

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.