当前位置: 首页>>代码示例>>Java>>正文


Java MiningSchema类代码示例

本文整理汇总了Java中weka.core.pmml.MiningSchema的典型用法代码示例。如果您正苦于以下问题:Java MiningSchema类的具体用法?Java MiningSchema怎么用?Java MiningSchema使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MiningSchema类属于weka.core.pmml包,在下文中一共展示了MiningSchema类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ScoreDistribution

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Construct a ScoreDistribution entry
 * 
 * @param scoreE the node containing the distribution
 * @param miningSchema the mining schema
 * @param baseCount the number of records at the node that owns this
 *          distribution entry
 * @throws Exception if something goes wrong
 */
protected ScoreDistribution(Element scoreE, MiningSchema miningSchema,
  double baseCount) throws Exception {
  // get the label
  m_classLabel = scoreE.getAttribute("value");
  Attribute classAtt = miningSchema.getFieldsAsInstances().classAttribute();
  if (classAtt == null || classAtt.indexOfValue(m_classLabel) < 0) {
    throw new Exception(
      "[ScoreDistribution] class attribute not set or class value "
        + m_classLabel + " not found!");
  }

  m_classLabelIndex = classAtt.indexOfValue(m_classLabel);

  // get the frequency
  String recordC = scoreE.getAttribute("recordCount");
  m_recordCount = Double.parseDouble(recordC);

  // get the optional confidence
  String confidence = scoreE.getAttribute("confidence");
  if (confidence != null && confidence.length() > 0) {
    m_confidence = Double.parseDouble(confidence);
  } else if (!Utils.isMissingValue(baseCount) && baseCount > 0) {
    m_confidence = m_recordCount / baseCount;
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:35,代码来源:TreeModel.java

示例2: NeuralInput

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
protected NeuralInput(Element input, MiningSchema miningSchema) throws Exception {
  m_ID = input.getAttribute("id");
  
  NodeList fL = input.getElementsByTagName("DerivedField");
  if (fL.getLength() != 1) {
    throw new Exception("[NeuralInput] expecting just one derived field!");
  }
  
  Element dF = (Element)fL.item(0);
  Instances allFields = miningSchema.getFieldsAsInstances();
  ArrayList<Attribute> fieldDefs = new ArrayList<Attribute>();
  for (int i = 0; i < allFields.numAttributes(); i++) {
    fieldDefs.add(allFields.attribute(i));
  }
  m_field = new DerivedFieldMetaInfo(dF, fieldDefs, miningSchema.getTransformationDictionary());
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:17,代码来源:NeuralNetwork.java

示例3: ScoreDistribution

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Construct a ScoreDistribution entry
 * 
 * @param scoreE the node containing the distribution
 * @param miningSchema the mining schema
 * @param baseCount the number of records at the node that owns this 
 * distribution entry
 * @throws Exception if something goes wrong
 */
protected ScoreDistribution(Element scoreE, MiningSchema miningSchema, double baseCount) 
  throws Exception {
  // get the label
  m_classLabel = scoreE.getAttribute("value");
  Attribute classAtt = miningSchema.getFieldsAsInstances().classAttribute();
  if (classAtt == null || classAtt.indexOfValue(m_classLabel) < 0) {
    throw new Exception("[ScoreDistribution] class attribute not set or class value " +
        m_classLabel + " not found!");
  }
  
  m_classLabelIndex = classAtt.indexOfValue(m_classLabel);
  
  // get the frequency
  String recordC = scoreE.getAttribute("recordCount");
  m_recordCount = Double.parseDouble(recordC);
  
  // get the optional confidence
  String confidence = scoreE.getAttribute("confidence");
  if (confidence != null && confidence.length() > 0) {
    m_confidence = Double.parseDouble(confidence);        
  } else if (!Utils.isMissingValue(baseCount) && baseCount > 0) {
    m_confidence = m_recordCount / baseCount;
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:34,代码来源:TreeModel.java

示例4: getPredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Factory method to return the appropriate predicate for a given node in
 * the tree.
 * 
 * @param nodeE the XML node encapsulating the tree node.
 * @param miningSchema the mining schema in use
 * @return a Predicate
 * @throws Exception of something goes wrong.
 */
static Predicate getPredicate(Element nodeE, MiningSchema miningSchema)
  throws Exception {

  Predicate result = null;
  NodeList children = nodeE.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element) child).getTagName();
      if (tagName.equals("True")) {
        result = new True();
        break;
      } else if (tagName.equals("False")) {
        result = new False();
        break;
      } else if (tagName.equals("SimplePredicate")) {
        result = new SimplePredicate((Element) child, miningSchema);
        break;
      } else if (tagName.equals("CompoundPredicate")) {
        result = new CompoundPredicate((Element) child, miningSchema);
        break;
      } else if (tagName.equals("SimpleSetPredicate")) {
        result = new SimpleSetPredicate((Element) child, miningSchema);
        break;
      }
    }
  }

  if (result == null) {
    throw new Exception(
      "[Predicate] unknown or missing predicate type in node");
  }

  return result;
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:45,代码来源:TreeModel.java

示例5: CompoundPredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
public CompoundPredicate(Element compoundP, MiningSchema miningSchema) throws Exception {
  // Instances totalStructure = miningSchema.getFieldsAsInstances();

  String booleanOpp = compoundP.getAttribute("booleanOperator");
  for (BooleanOperator b : BooleanOperator.values()) {
    if (b.toString().equals(booleanOpp)) {
      m_booleanOperator = b;
    }
  }

  // now get all the encapsulated operators
  NodeList children = compoundP.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element) child).getTagName();
      if (tagName.equals("True")) {
        m_components.add(new True());
      } else if (tagName.equals("False")) {
        m_components.add(new False());
      } else if (tagName.equals("SimplePredicate")) {
        m_components
          .add(new SimplePredicate((Element) child, miningSchema));
      } else if (tagName.equals("CompoundPredicate")) {
        m_components.add(new CompoundPredicate((Element) child,
          miningSchema));
      } else {
        m_components.add(new SimpleSetPredicate((Element) child,
          miningSchema));
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:34,代码来源:TreeModel.java

示例6: getChildNodes

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
private void getChildNodes(Element nodeE, MiningSchema miningSchema)
  throws Exception {
  NodeList children = nodeE.getChildNodes();

  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element) child).getTagName();
      if (tagName.equals("Node")) {
        TreeNode tempN = new TreeNode((Element) child, miningSchema);
        m_childNodes.add(tempN);
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:16,代码来源:TreeModel.java

示例7: RuleSetModel

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Constructor for a RuleSetModel
 * 
 * @param model the XML element encapsulating the RuleSetModel
 * @param dataDictionary the data dictionary to use
 * @param miningSchema the mining schema to use
 * @throws Exception if something goes wrong
 */
public RuleSetModel(Element model, Instances dataDictionary,
    MiningSchema miningSchema) throws Exception {
  
  super(dataDictionary, miningSchema);
  
  if (!getPMMLVersion().equals("3.2")) {
    // TODO: might have to throw an exception and only support 3.2
  }
  
  String fn = model.getAttribute("functionName");
  if (fn.equals("regression")) {
    m_functionType = MiningFunction.REGRESSION;
  }
  
  String modelName = model.getAttribute("modelName");
  if (modelName != null && modelName.length() > 0) {
    m_modelName = modelName;
  }
  
  String algoName = model.getAttribute("algorithmName");
  if (algoName != null && algoName.length() > 0) {
    m_algorithmName = algoName;
  }    
  
  NodeList ruleset = model.getElementsByTagName("RuleSet");
  if (ruleset.getLength() == 1) {
    Node ruleSetNode = ruleset.item(0);
    if (ruleSetNode.getNodeType() == Node.ELEMENT_NODE) {
      m_ruleSet = new RuleSet((Element)ruleSetNode, miningSchema);
    }
  } else {
    throw new Exception ("[RuleSetModel] Should only have a single RuleSet!");
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:43,代码来源:RuleSetModel.java

示例8: Regression

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Constructs a new PMML Regression.
 * 
 * @param model the <code>Element</code> containing the regression model
 * @param dataDictionary the data dictionary as an Instances object
 * @param miningSchema the mining schema
 * @throws Exception if there is a problem constructing this Regression
 */
public Regression(Element model, Instances dataDictionary,
                  MiningSchema miningSchema) throws Exception {
  super(dataDictionary, miningSchema);
  
  int functionType = RegressionTable.REGRESSION;

  // determine function name first
  String fName = model.getAttribute("functionName");
  
  if (fName.equals("regression")) {
    functionType = RegressionTable.REGRESSION;
  } else if (fName.equals("classification")) {
    functionType = RegressionTable.CLASSIFICATION;
  } else {
    throw new Exception("[PMML Regression] Function name not defined in pmml!");
  }

  // do we have an algorithm name?
  String algName = model.getAttribute("algorithmName");
  if (algName != null && algName.length() > 0) {
    m_algorithmName = algName;
  }

  // determine normalization method (if any)
  m_normalizationMethod = determineNormalization(model);

  setUpRegressionTables(model, functionType);

  // convert any string attributes in the mining schema
  //miningSchema.convertStringAttsToNominal();
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:40,代码来源:Regression.java

示例9: getPredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
/**
 * Factory method to return the appropriate predicate for
 * a given node in the tree.
 * 
 * @param nodeE the XML node encapsulating the tree node.
 * @param miningSchema the mining schema in use
 * @return a Predicate
 * @throws Exception of something goes wrong.
 */
static Predicate getPredicate(Element nodeE, 
    MiningSchema miningSchema) throws Exception {
  
  Predicate result = null;
  NodeList children = nodeE.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element)child).getTagName();
      if (tagName.equals("True")) {
        result = new True();
        break;
      } else if (tagName.equals("False")) {
        result = new False();
        break;
      } else if (tagName.equals("SimplePredicate")) {
        result = new SimplePredicate((Element)child, miningSchema);
        break;
      } else if (tagName.equals("CompoundPredicate")) {
        result = new CompoundPredicate((Element)child, miningSchema);
        break;
      } else if (tagName.equals("SimpleSetPredicate")) {
       result = new SimpleSetPredicate((Element)child, miningSchema);
       break;
      }
    }
  }
  
  if (result == null) {
    throw new Exception("[Predicate] unknown or missing predicate type in node");
  }
  
  return result;
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:44,代码来源:TreeModel.java

示例10: CompoundPredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
public CompoundPredicate(Element compoundP, 
        MiningSchema miningSchema) throws Exception {
//      Instances totalStructure = miningSchema.getFieldsAsInstances();
      
      String booleanOpp = compoundP.getAttribute("booleanOperator");
      for (BooleanOperator b : BooleanOperator.values()) {
        if (b.toString().equals(booleanOpp)) {
          m_booleanOperator = b;
        }
      }
      
      // now get all the encapsulated operators
      NodeList children = compoundP.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE) {
          String tagName = ((Element)child).getTagName();
          if (tagName.equals("True")) {
            m_components.add(new True());
          } else if (tagName.equals("False")) {
            m_components.add(new False());
          } else if (tagName.equals("SimplePredicate")) {
            m_components.add(new SimplePredicate((Element)child, miningSchema));
          } else if (tagName.equals("CompoundPredicate")) {
            m_components.add(new CompoundPredicate((Element)child, miningSchema));
          } else {
            m_components.add(new SimpleSetPredicate((Element)child, miningSchema));
          }
        }
      }
    }
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:32,代码来源:TreeModel.java

示例11: getChildNodes

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
private void getChildNodes(Element nodeE, MiningSchema miningSchema) throws Exception {
  NodeList children = nodeE.getChildNodes();
  
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element)child).getTagName();
      if (tagName.equals("Node")) {
        TreeNode tempN = new TreeNode((Element)child, miningSchema);
        m_childNodes.add(tempN);
      }
    }
  }
}
 
开发者ID:dsibournemouth,项目名称:autoweka,代码行数:15,代码来源:TreeModel.java

示例12: SimplePredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
public SimplePredicate(Element simpleP, MiningSchema miningSchema) throws Exception {
  Instances totalStructure = miningSchema.getFieldsAsInstances();

  // get the field name and set up the index
  String fieldS = simpleP.getAttribute("field");
  Attribute att = totalStructure.attribute(fieldS);
  if (att == null) {
    throw new Exception("[SimplePredicate] unable to find field " + fieldS
      + " in the incoming instance structure!");
  }

  // find the index
  int index = -1;
  for (int i = 0; i < totalStructure.numAttributes(); i++) {
    if (totalStructure.attribute(i).name().equals(fieldS)) {
      index = i;
      m_fieldName = totalStructure.attribute(i).name();
      break;
    }
  }
  m_fieldIndex = index;
  if (att.isNominal()) {
    m_isNominal = true;
  }

  // get the operator
  String oppS = simpleP.getAttribute("operator");
  for (Operator o : Operator.values()) {
    if (o.toString().equals(oppS)) {
      m_operator = o;
      break;
    }
  }

  if (m_operator != Operator.ISMISSING
    && m_operator != Operator.ISNOTMISSING) {
    String valueS = simpleP.getAttribute("value");
    if (att.isNumeric()) {
      m_value = Double.parseDouble(valueS);
    } else {
      m_nominalValue = valueS;
      m_value = att.indexOfValue(valueS);
      if (m_value < 0) {
        throw new Exception("[SimplePredicate] can't find value " + valueS
          + " in nominal " + "attribute " + att.name());
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:50,代码来源:TreeModel.java

示例13: SimpleSetPredicate

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
public SimpleSetPredicate(Element setP, MiningSchema miningSchema) throws Exception {
  Instances totalStructure = miningSchema.getFieldsAsInstances();

  // get the field name and set up the index
  String fieldS = setP.getAttribute("field");
  Attribute att = totalStructure.attribute(fieldS);
  if (att == null) {
    throw new Exception("[SimplePredicate] unable to find field " + fieldS
      + " in the incoming instance structure!");
  }

  // find the index
  int index = -1;
  for (int i = 0; i < totalStructure.numAttributes(); i++) {
    if (totalStructure.attribute(i).name().equals(fieldS)) {
      index = i;
      m_fieldName = totalStructure.attribute(i).name();
      break;
    }
  }
  m_fieldIndex = index;
  if (att.isNominal()) {
    m_isNominal = true;
    m_nominalLookup = att;
  }

  // need to scan the children looking for an array type
  NodeList children = setP.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      if (Array.isArray((Element) child)) {
        // found the array
        m_set = Array.create((Element) child);
        break;
      }
    }
  }

  if (m_set == null) {
    throw new Exception("[SimpleSetPredictate] couldn't find an "
      + "array containing the set values!");
  }

  // check array type against field type
  if (m_set.getType() == Array.ArrayType.STRING && !m_isNominal) {
    throw new Exception("[SimpleSetPredicate] referenced field "
      + totalStructure.attribute(m_fieldIndex).name()
      + " is numeric but array type is string!");
  } else if (m_set.getType() != Array.ArrayType.STRING && m_isNominal) {
    throw new Exception("[SimpleSetPredicate] referenced field "
      + totalStructure.attribute(m_fieldIndex).name()
      + " is nominal but array type is numeric!");
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:56,代码来源:TreeModel.java

示例14: TreeNode

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
protected TreeNode(Element nodeE, MiningSchema miningSchema) throws Exception {
  Attribute classAtt = miningSchema.getFieldsAsInstances().classAttribute();

  // get the ID
  String id = nodeE.getAttribute("id");
  if (id != null && id.length() > 0) {
    m_ID = id;
  }

  // get the score for this node
  String scoreS = nodeE.getAttribute("score");
  if (scoreS != null && scoreS.length() > 0) {
    m_scoreString = scoreS;

    // try to parse as a number in case we
    // are part of a regression tree
    if (classAtt.isNumeric()) {
      try {
        m_scoreNumeric = Double.parseDouble(scoreS);
      } catch (NumberFormatException ex) {
        throw new Exception(
          "[TreeNode] class is numeric but unable to parse score "
            + m_scoreString + " as a number!");
      }
    } else {
      // store the index of this class value
      m_scoreIndex = classAtt.indexOfValue(m_scoreString);

      if (m_scoreIndex < 0) {
        throw new Exception(
          "[TreeNode] can't find match for predicted value "
            + m_scoreString + " in class attribute!");
      }
    }
  }

  // get the record count if defined
  String recordC = nodeE.getAttribute("recordCount");
  if (recordC != null && recordC.length() > 0) {
    m_recordCount = Double.parseDouble(recordC);
  }

  // get the default child (if applicable)
  String defaultC = nodeE.getAttribute("defaultChild");
  if (defaultC != null && defaultC.length() > 0) {
    m_defaultChildID = defaultC;
  }

  // TODO: Embedded model (once we support model composition)

  // Now get the ScoreDistributions (if any and mining function
  // is classification) at this level
  if (m_functionType == MiningFunction.CLASSIFICATION) {
    getScoreDistributions(nodeE, miningSchema);
  }

  // Now get the Predicate
  m_predicate = Predicate.getPredicate(nodeE, miningSchema);

  // Now get the child Node(s)
  getChildNodes(nodeE, miningSchema);

  // If we have a default child specified, find it now
  if (m_defaultChildID != null) {
    for (TreeNode t : m_childNodes) {
      if (t.getID().equals(m_defaultChildID)) {
        m_defaultChild = t;
        break;
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:73,代码来源:TreeModel.java

示例15: TreeModel

import weka.core.pmml.MiningSchema; //导入依赖的package包/类
public TreeModel(Element model, Instances dataDictionary,
  MiningSchema miningSchema) throws Exception {

  super(dataDictionary, miningSchema);

  if (!getPMMLVersion().equals("3.2")) {
    // TODO: might have to throw an exception and only support 3.2
  }

  String fn = model.getAttribute("functionName");
  if (fn.equals("regression")) {
    m_functionType = MiningFunction.REGRESSION;
  }

  // get the missing value strategy (if any)
  String missingVS = model.getAttribute("missingValueStrategy");
  if (missingVS != null && missingVS.length() > 0) {
    for (MissingValueStrategy m : MissingValueStrategy.values()) {
      if (m.toString().equals(missingVS)) {
        m_missingValueStrategy = m;
        break;
      }
    }
  }

  // get the missing value penalty (if any)
  String missingP = model.getAttribute("missingValuePenalty");
  if (missingP != null && missingP.length() > 0) {
    // try to parse as a number
    try {
      m_missingValuePenalty = Double.parseDouble(missingP);
    } catch (NumberFormatException ex) {
      System.err.println("[TreeModel] WARNING: "
        + "couldn't parse supplied missingValuePenalty as a number");
    }
  }

  String splitC = model.getAttribute("splitCharacteristic");

  if (splitC != null && splitC.length() > 0) {
    for (SplitCharacteristic s : SplitCharacteristic.values()) {
      if (s.toString().equals(splitC)) {
        m_splitCharacteristic = s;
        break;
      }
    }
  }

  // find the root node of the tree
  NodeList children = model.getChildNodes();
  for (int i = 0; i < children.getLength(); i++) {
    Node child = children.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
      String tagName = ((Element) child).getTagName();
      if (tagName.equals("Node")) {
        m_root = new TreeNode((Element) child, miningSchema);
        break;
      }
    }
  }
}
 
开发者ID:mydzigear,项目名称:repo.kmeanspp.silhouette_score,代码行数:62,代码来源:TreeModel.java


注:本文中的weka.core.pmml.MiningSchema类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。