Package weka.core

Examples of weka.core.Attribute.index()


        // We need to create a new Attribute that has the ClusterId
        Instances newData = data; // new Instances(data);
        newData.insertAttributeAt(new Attribute("ClusterId"), newData.numAttributes());
        Attribute cluster_attr = newData.attribute(newData.numAttributes()-1);
        assert(cluster_attr != null);
        assert(cluster_attr.index() > 0);
        newData.setClass(cluster_attr);
       
        // We will then tell the Classifier to predict that ClusterId based on the MarkovAttributeSet
        ObjectHistogram<Integer> cluster_h = new ObjectHistogram<Integer>();
        for (int i = 0, cnt = newData.numInstances(); i < cnt; i++) {
View Full Code Here


    // Compute attribute with maximum information gain.
    double[] infoGains = new double[data.numAttributes()];
    Enumeration attEnum = data.enumerateAttributes();
    while (attEnum.hasMoreElements()) {
      Attribute att = (Attribute) attEnum.nextElement();
      infoGains[att.index()] = computeInfoGain(data, att);
    }
    m_Attribute = data.attribute(Utils.maxIndex(infoGains));
   
    // Make leaf if information gain is zero.
    // Otherwise create successors.
View Full Code Here

        m_miningSchema.getFieldsAsInstances().attribute(m_offsetVariable);
      if (offsetAtt == null) {
        throw new Exception("[GeneralRegression] unable to find offset variable "
            + m_offsetVariable + " in the mining schema!");
      }
      offset = incomingInst[offsetAtt.index()];
    } else if (!Double.isNaN(m_offsetValue)) {
      offset = m_offsetValue;
    }
   
    double trials = 1;
View Full Code Here

      Attribute trialsAtt = m_miningSchema.getFieldsAsInstances().attribute(m_trialsVariable);
      if (trialsAtt == null) {
        throw new Exception("[GeneralRegression] unable to find trials variable "
            + m_trialsVariable + " in the mining schema!");
      }
      trials = incomingInst[trialsAtt.index()];
    } else if (!Double.isNaN(m_trialsValue)) {
      trials = m_trialsValue;
    }
   
    double distParam = 0;
View Full Code Here

        m_miningSchema.getFieldsAsInstances().attribute(m_offsetVariable);
      if (offsetAtt == null) {
        throw new Exception("[GeneralRegression] unable to find offset variable "
            + m_offsetVariable + " in the mining schema!");
      }
      offset = incomingInst[offsetAtt.index()];
    } else if (!Double.isNaN(m_offsetValue)) {
      offset = m_offsetValue;
    }
   
    for (int i = 0; i < r.length; i++) {
View Full Code Here

          if(att.isNumeric())
            antd = new NumericAntd(att);
          else
            antd = new NominalAntd(att);

          if(!used[att.index()]){
            /* Compute the best information gain for each attribute,
               it's stored in the antecedent formed by this attribute.
               This procedure returns the data covered by the antecedent*/
            Instances coveredData = computeInfoGain(growData, defAcRt,
                antd);
View Full Code Here

    Enumeration enu = instances.enumerateAttributes();   
    while (enu.hasMoreElements()) {
      Attribute attribute = (Attribute) enu.nextElement();
      if (attribute.type() != Attribute.NOMINAL) {
  m_nNonDiscreteAttribute = attribute.index();
  bHasNonNominal = true;
  //throw new UnsupportedAttributeTypeException("BayesNet handles nominal variables only. Non-nominal variable in dataset detected.");
      }
      Enumeration enum2 = instances.enumerateInstances();
      while (enum2.hasMoreElements()) {
View Full Code Here

      if (att == null) {
        System.err.println("[FPGrowth] : WARNING - can't find attribute "
            + attName + " in the data.");
        numInTransactionsMustContainList--;
      } else {
        transactionsMustContainIndexes[att.index()] = true;
      }
    }
   
    if (numInTransactionsMustContainList == 0) {
      return data;
View Full Code Here

      }     
    }
   
    Attribute att = insts.attribute(attName);
    if (att != null) {
      return att.index();
    }
   
    return -1; // not found
 
}
View Full Code Here

      // nothing to do
    } else {
      // try to look up class attribute as a label
      Attribute classAtt = format.attribute(classColString);
      if (classAtt != null) {
        existingClassCol = classAtt.index();
      } else {
        // parse it as a number
        existingClassCol = Integer.parseInt(classColString);
        if (existingClassCol < 0) {
          existingClassCol = -1; // no class
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.