Package weka.core

Examples of weka.core.Instances.classAttribute()


      else {
  data = sparse;
      }
     
      // fix class
      if (result.classAttribute().isNominal()) {
  if (data[data.length - 1] == 1.0)
    data[data.length - 1] = result.classAttribute().indexOfValue("+1");
  else if (data[data.length - 1] == -1)
    data[data.length - 1] = result.classAttribute().indexOfValue("-1");
  else
View Full Code Here


      }
     
      // fix class
      if (result.classAttribute().isNominal()) {
  if (data[data.length - 1] == 1.0)
    data[data.length - 1] = result.classAttribute().indexOfValue("+1");
  else if (data[data.length - 1] == -1)
    data[data.length - 1] = result.classAttribute().indexOfValue("-1");
  else
    throw new IllegalStateException("Class is not binary!");
      }
View Full Code Here

      // fix class
      if (result.classAttribute().isNominal()) {
  if (data[data.length - 1] == 1.0)
    data[data.length - 1] = result.classAttribute().indexOfValue("+1");
  else if (data[data.length - 1] == -1)
    data[data.length - 1] = result.classAttribute().indexOfValue("-1");
  else
    throw new IllegalStateException("Class is not binary!");
      }
     
      result.add(new SparseInstance(1, data));
View Full Code Here

    super.setInputFormat(instanceInfo);

    /* create a new output format (multi-instance format) */
    Instances newData = instanceInfo.stringFreeStructure();
    Attribute attBagIndex = (Attribute) newData.attribute(0).copy();
    Attribute attClass = (Attribute) newData.classAttribute().copy();
    // remove the bagIndex attribute
    newData.deleteAttributeAt(0);
    // remove the class attribute
    newData.setClassIndex(-1);
    newData.deleteAttributeAt(newData.numAttributes() - 1);
View Full Code Here

        TargetMetaInfo targetData = m_miningSchema.getTargetMetaData();
        if (m_miningSchema.getFieldsAsInstances().classAttribute().isNumeric()) {
          preds[0] = targetData.getDefaultValue();
        } else {
          Instances miningSchemaI = m_miningSchema.getFieldsAsInstances();
          for (int i = 0; i < miningSchemaI.classAttribute().numValues(); i++) {
            preds[i] = targetData.getPriorProbability(miningSchemaI.classAttribute().value(i));
          }
        }
        return preds;
      }
View Full Code Here

        if (m_miningSchema.getFieldsAsInstances().classAttribute().isNumeric()) {
          preds[0] = targetData.getDefaultValue();
        } else {
          Instances miningSchemaI = m_miningSchema.getFieldsAsInstances();
          for (int i = 0; i < miningSchemaI.classAttribute().numValues(); i++) {
            preds[i] = targetData.getPriorProbability(miningSchemaI.classAttribute().value(i));
          }
        }
        return preds;
      }
    } else {
View Full Code Here

     */
    public String toString() {
      Instances miningSchema = m_miningSchema.getFieldsAsInstances();
      StringBuffer temp = new StringBuffer();
      temp.append("Regression table:\n");
      temp.append(miningSchema.classAttribute().name());
      if (m_functionType == CLASSIFICATION) {
        temp.append("=" + miningSchema.
                    classAttribute().value(m_targetCategory));
      }

View Full Code Here

      Instances miningSchema = m_miningSchema.getFieldsAsInstances();
      StringBuffer temp = new StringBuffer();
      temp.append("Regression table:\n");
      temp.append(miningSchema.classAttribute().name());
      if (m_functionType == CLASSIFICATION) {
        temp.append("=" + miningSchema.
                    classAttribute().value(m_targetCategory));
      }

      temp.append(" =\n\n");
     
View Full Code Here

      // get the target category (if classification)
      if (m_functionType == CLASSIFICATION) {
        // target category MUST be defined
        String targetCat = table.getAttribute("targetCategory");
        if (targetCat.length() > 0) {
          Attribute classA = miningSchema.classAttribute();
          for (int i = 0; i < classA.numValues(); i++) {
            if (classA.value(i).equals(targetCat)) {
              m_targetCategory = i;
            }
          }
View Full Code Here

              } else {
          if (classifier instanceof PMMLClassifier) {
            // set the class based on information in the mining schema
            Instances miningSchemaStructure =
              ((PMMLClassifier)classifier).getMiningSchema().getMiningSchemaAsInstances();
            String className = miningSchemaStructure.classAttribute().name();
            Attribute classMatch = userTestStructure.attribute(className);
            if (classMatch == null) {
              throw new Exception(Messages.getInstance().getString("ClassifierPanel_ReEvaluateModel_Exception_Text_Fourth")
            + className + Messages.getInstance().getString("ClassifierPanel_ReEvaluateModel_Exception_Text_Fifth"));
            }
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.