Java Code Examples for weka.core.pmml.Array

The following are top voted examples for showing how to use weka.core.pmml.Array. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: repo.kmeanspp.silhouette_score   File: TreeModel.java   Source Code and License 6 votes vote down vote up
@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]));
}
 
Example 2
Project: autoweka   File: TreeModel.java   Source Code and License 6 votes vote down vote up
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]));
}
 
Example 3
Project: umple   File: TreeModel.java   Source Code and License 6 votes vote down vote up
@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]));
}
 
Example 4
Project: repo.kmeanspp.silhouette_score   File: TreeModel.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 5
Project: autoweka   File: TreeModel.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 6
Project: umple   File: TreeModel.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 7
Project: repo.kmeanspp.silhouette_score   File: TreeModel.java   Source Code and License 4 votes vote down vote up
abstract Predicate.Eval evaluate(double[] input, int fieldIndex,
Array set, Attribute nominalLookup);
 
Example 8
Project: repo.kmeanspp.silhouette_score   File: TreeModel.java   Source Code and License 4 votes vote down vote up
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!");
  }
}
 
Example 9
Project: autoweka   File: TreeModel.java   Source Code and License 4 votes vote down vote up
abstract Predicate.Eval evaluate(double[] input, int fieldIndex, 
Array set, Attribute nominalLookup);
 
Example 10
Project: autoweka   File: TreeModel.java   Source Code and License 4 votes vote down vote up
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!");
  }      
}
 
Example 11
Project: umple   File: TreeModel.java   Source Code and License 4 votes vote down vote up
abstract Predicate.Eval evaluate(double[] input, int fieldIndex,
Array set, Attribute nominalLookup);
 
Example 12
Project: umple   File: TreeModel.java   Source Code and License 4 votes vote down vote up
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!");
  }
}