本文整理汇总了Java中weka.core.pmml.Array类的典型用法代码示例。如果您正苦于以下问题:Java Array类的具体用法?Java Array怎么用?Java Array使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Array类属于weka.core.pmml包,在下文中一共展示了Array类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import weka.core.pmml.Array; //导入依赖的package包/类
@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]));
}
示例2: evaluate
import weka.core.pmml.Array; //导入依赖的package包/类
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]));
}
示例3: SimpleSetPredicate
import weka.core.pmml.Array; //导入依赖的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!");
}
}
示例4: SimpleSetPredicate
import weka.core.pmml.Array; //导入依赖的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!");
}
}