@Override Predicate.Eval evaluate(double[] input, int fieldIndex, Array set, Attribute nominalLookup) { if (set.getType() == Array.ArrayType.STRING) { String value = ""; if (!Utils.isMissingValue(input[fieldIndex])) { value = nominalLookup.value((int) input[fieldIndex]); } return Predicate.booleanToEval( Utils.isMissingValue(input[fieldIndex]), set.contains(value)); } else if (set.getType() == Array.ArrayType.NUM || set.getType() == Array.ArrayType.REAL) { return Predicate.booleanToEval( Utils.isMissingValue(input[fieldIndex]), set.contains(input[fieldIndex])); } return Predicate.booleanToEval( Utils.isMissingValue(input[fieldIndex]), set.contains((int) input[fieldIndex])); }
Predicate.Eval evaluate(double[] input, int fieldIndex, Array set, Attribute nominalLookup) { if (set.getType() == Array.ArrayType.STRING) { String value = ""; if (!Utils.isMissingValue(input[fieldIndex])) { value = nominalLookup.value((int)input[fieldIndex]); } return Predicate.booleanToEval(Utils.isMissingValue(input[fieldIndex]), set.contains(value)); } else if (set.getType() == Array.ArrayType.NUM || set.getType() == Array.ArrayType.REAL) { return Predicate.booleanToEval(Utils.isMissingValue(input[fieldIndex]), set.contains(input[fieldIndex])); } return Predicate.booleanToEval(Utils.isMissingValue(input[fieldIndex]), set.contains((int)input[fieldIndex])); }
@Override Predicate.Eval evaluate(double[] input, int fieldIndex, Array set, Attribute nominalLookup) { Predicate.Eval result = IS_IN.evaluate(input, fieldIndex, set, nominalLookup); if (result == Predicate.Eval.FALSE) { result = Predicate.Eval.TRUE; } else if (result == Predicate.Eval.TRUE) { result = Predicate.Eval.FALSE; } return result; }
Predicate.Eval evaluate(double[] input, int fieldIndex, Array set, Attribute nominalLookup) { Predicate.Eval result = IS_IN.evaluate(input, fieldIndex, set, nominalLookup); if (result == Predicate.Eval.FALSE) { result = Predicate.Eval.TRUE; } else if (result == Predicate.Eval.TRUE) { result = Predicate.Eval.FALSE; } return result; }
abstract Predicate.Eval evaluate(double[] input, int fieldIndex, Array set, Attribute nominalLookup);
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!"); } }
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!"); } }