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