} else { if (trueNode != null) { preds = trueNode.score(instance, classAtt); } else { doNoTrueChild(classAtt, preds);
} else { if (trueNode != null) { preds = trueNode.score(instance, classAtt); } else { doNoTrueChild(classAtt, preds);
preds = c.score(instance, classAtt); break; } else if (c.getPredicate().evaluate(instance) == Predicate.Eval.UNKNOWN) {
preds = c.score(instance, classAtt); break; } else if (c.getPredicate().evaluate(instance) == Predicate.Eval.UNKNOWN) {
preds = c.score(instance, classAtt); break; } else if (c.getPredicate().evaluate(instance) == Predicate.Eval.UNKNOWN) {
preds = c.score(instance, classAtt); break; } else if (c.getPredicate().evaluate(instance) == Predicate.Eval.UNKNOWN) {
/** * Compute predictions and optionally invoke the "none" missing value * handling strategy (invokes no true child). * * @param instance the incoming vector of attribute and derived field * values. * @param classAtt the class attribute. * @return the predicted probability distribution. * @throws Exception if something goes wrong. */ protected double[] missingValueStrategyNone(double[] instance, Attribute classAtt) throws Exception { double[] preds = null; // look for a child whose predicate evaluates to TRUE for (TreeNode c : m_childNodes) { if (c.getPredicate().evaluate(instance) == Predicate.Eval.TRUE) { preds = c.score(instance, classAtt); break; } } if (preds == null) { preds = new double[classAtt.numValues()]; // no true child strategy doNoTrueChild(classAtt, preds); } return preds; } }
/** * Classifies the given test instance. The instance has to belong to a dataset * when it's being classified. * * @param inst the instance to be classified * @return the predicted most likely class for the instance or * Utils.missingValue() if no prediction is made * @exception Exception if an error occurred during the prediction */ @Override public double[] distributionForInstance(Instance inst) throws Exception { if (!m_initialized) { mapToMiningSchema(inst.dataset()); } double[] preds = null; if (m_miningSchema.getFieldsAsInstances().classAttribute().isNumeric()) { preds = new double[1]; } else { preds = new double[m_miningSchema.getFieldsAsInstances().classAttribute() .numValues()]; } double[] incoming = m_fieldsMap.instanceToSchema(inst, m_miningSchema); preds = m_root.score(incoming, m_miningSchema.getFieldsAsInstances() .classAttribute()); return preds; }
/** * Compute predictions and optionally invoke the "none" missing value * handling strategy (invokes no true child). * * @param instance the incoming vector of attribute and derived field * values. * @param classAtt the class attribute. * @return the predicted probability distribution. * @throws Exception if something goes wrong. */ protected double[] missingValueStrategyNone(double[] instance, Attribute classAtt) throws Exception { double[] preds = null; // look for a child whose predicate evaluates to TRUE for (TreeNode c : m_childNodes) { if (c.getPredicate().evaluate(instance) == Predicate.Eval.TRUE) { preds = c.score(instance, classAtt); break; } } if (preds == null) { preds = new double[classAtt.numValues()]; // no true child strategy doNoTrueChild(classAtt, preds); } return preds; } }
/** * Classifies the given test instance. The instance has to belong to a dataset * when it's being classified. * * @param inst the instance to be classified * @return the predicted most likely class for the instance or * Utils.missingValue() if no prediction is made * @exception Exception if an error occurred during the prediction */ @Override public double[] distributionForInstance(Instance inst) throws Exception { if (!m_initialized) { mapToMiningSchema(inst.dataset()); } double[] preds = null; if (m_miningSchema.getFieldsAsInstances().classAttribute().isNumeric()) { preds = new double[1]; } else { preds = new double[m_miningSchema.getFieldsAsInstances().classAttribute() .numValues()]; } double[] incoming = m_fieldsMap.instanceToSchema(inst, m_miningSchema); preds = m_root.score(incoming, m_miningSchema.getFieldsAsInstances() .classAttribute()); return preds; }