Package weka.core

Examples of weka.core.Instances.classIndex()


   *
   * @return the dataset
   */
  public static Instances readInstances(String location) throws Exception {
    Instances data = new weka.core.converters.ConverterUtils.DataSource(location).getDataSet();
    if (data.classIndex() == -1)
      data.setClassIndex(data.numAttributes() - 1);
    return data;
  }
}
View Full Code Here


    Map<ClusterClass, List<StoredDomainCluster>> retval =
        new HashMap<ClusterClass, List<StoredDomainCluster>>();
    try{
      DataSource source = new DataSource(new ByteArrayInputStream(prepfeatures.getBytes()));
      Instances data = source.getDataSet();
      if (data.classIndex() == -1){
        data.setClassIndex(data.numAttributes() - 1);
      }
      String[] options = weka.core.Utils.splitOptions("-p 0");
      J48 cls = (J48)weka.core.SerializationHelper.read(modelfile);
      cls.setOptions(options);
View Full Code Here

      for (int i = 0; i < data.numClasses(); i++) {
  values.addElement(data.classAttribute().value(m_Converter[i]));
      }
      FastVector newVec = new FastVector(data.numAttributes());
      for (int i = 0; i < data.numAttributes(); i++) {
  if (i == data.classIndex()) {
    newVec.addElement(new Attribute(data.classAttribute().name(), values,
            data.classAttribute().getMetadata()));
  } else {
    newVec.addElement(data.attribute(i));
  }
View Full Code Here

        //notifyInstanceListeners(e);
  //  Instances dataset = e.getInstance().dataset();
  Instances dataset = e.getStructure();
  if (m_Filter instanceof SupervisedFilter) {
    // defualt to last column if no class is set
    if (dataset.classIndex() < 0) {
      dataset.setClassIndex(dataset.numAttributes()-1);
    }
  }
  // initialize filter
  m_Filter.setInputFormat(dataset);
View Full Code Here

        }
        values[attr.index()] = maxIndex;
      }
    }
  }
  values[sample.classIndex()] = minIndex;
  Instance synthetic = new Instance(1.0, values);
  push(synthetic);
  n--;
      }
    }
View Full Code Here

  public void testFilteredClassifier() {
    try {
      Instances data = getFilteredClassifierData();

      for (int i = 0; i < data.numAttributes(); i++) {
  if (data.classIndex() == i)
    continue;
  if (data.attribute(i).isNominal()) {
    ((RemoveFrequentValues) m_FilteredClassifier.getFilter()).setAttributeIndex(
        "" + (i + 1));
    break;
View Full Code Here

  public void testFilteredClassifier() {
    try {
      Instances data = getFilteredClassifierData();

      for (int i = 0; i < data.numAttributes(); i++) {
  if (data.classIndex() == i)
    continue;
  if (data.attribute(i).isNominal()) {
    ((NominalToString) m_FilteredClassifier.getFilter()).setAttributeIndexes(
        "" + (i + 1));
    break;
View Full Code Here

        m_instanceCount++;
  Instance inst = ce.getCurrentInstance();
  //  if (inst.attribute(inst.classIndex()).isNominal()) {
  double [] dist = ce.getClassifier().distributionForInstance(inst);
  double pred = 0;
  if (!inst.isMissing(inst.classIndex())) {
          if (m_outputInfoRetrievalStats) {
            // store predictions so AUC etc can be output.
            m_eval.evaluateModelOnceAndRecordPrediction(dist, inst);
          } else {
            m_eval.evaluateModelOnce(dist, inst);
View Full Code Here

            m_eval.evaluateModelOnce(dist, inst);
          }
  } else {
    pred = ce.getClassifier().classifyInstance(inst);
  }
  if (inst.classIndex() >= 0) {
    // need to check that the class is not missing
    if (inst.attribute(inst.classIndex()).isNominal()) {
      if (!inst.isMissing(inst.classIndex())) {
        if (m_dataPoint.length < 2) {
    m_dataPoint = new double[2];
View Full Code Here

  } else {
    pred = ce.getClassifier().classifyInstance(inst);
  }
  if (inst.classIndex() >= 0) {
    // need to check that the class is not missing
    if (inst.attribute(inst.classIndex()).isNominal()) {
      if (!inst.isMissing(inst.classIndex())) {
        if (m_dataPoint.length < 2) {
    m_dataPoint = new double[2];
    m_dataLegend.addElement("Accuracy");
    m_dataLegend.addElement("RMSE (prob)");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.