Package weka.core

Examples of weka.core.Instances.attribute()


    // Check conversion is OK
    for (int i = 0; i < result.numInstances(); i++) {
      for (int j = 0; j < result.numAttributes(); j++) {
        if (m_Instances.instance(i).isMissing(j)) {
          assertTrue(result.instance(i).isMissing(j));
        } else if (result.attribute(j).isNumeric()) {
          assertEquals("Value should be same as Math.abs()",
                       Math.abs(m_Instances.instance(i).value(j)),
                       result.instance(i).value(j), TOLERANCE);
        } else {
          assertEquals("Value shouldn't have changed",
View Full Code Here


    // Check conversion is OK
    for (int i = 0; i < result.numInstances(); i++) {
      for (int j = 0; j < result.numAttributes(); j++) {
        if (m_Instances.instance(i).isMissing(j)) {
          assertTrue(result.instance(i).isMissing(j));
        } else if (result.attribute(j).isNumeric() && (j >=3)) {
          assertEquals("Value should be same as Math.abs()",
                       Math.abs(m_Instances.instance(i).value(j)),
                       result.instance(i).value(j), TOLERANCE);
        } else {
          assertEquals("Value shouldn't have changed",
View Full Code Here

    // Check conversion is OK
    for (int i = 0; i < result.numInstances(); i++) {
      for (int j = 0; j < result.numAttributes(); j++) {
        if (m_Instances.instance(i).isMissing(j)) {
          assertTrue(result.instance(i).isMissing(j));
        } else if (result.attribute(j).isNumeric()) {
          assertEquals("Value should be same as Math.rint()",
                       Math.rint(m_Instances.instance(i).value(j)),
                       result.instance(i).value(j), TOLERANCE);
        } else {
          assertEquals("Value shouldn't have changed",
View Full Code Here

    // Number of attributes and instances shouldn't change
    assertEquals(m_Instances.numAttributes(), result.numAttributes());
    assertEquals(m_Instances.numInstances(), result.numInstances());
    for (int j = 0; j < m_Instances.numAttributes(); j++) {
      Attribute inatt = m_Instances.attribute(j);
      Attribute outatt = result.attribute(j);
      for (int i = 0; i < m_Instances.numInstances(); i++) {
        if (m_Instances.attribute(j).isString()) {
          if (m_Instances.instance(i).isMissing(j)) {
            assertTrue("Missing values in strings cannot be replaced",
                   result.instance(i).isMissing(j));
View Full Code Here

    m_Filter = getFilter();
    Instances result = useFilter();
    assertEquals(m_Instances.numAttributes(), result.numAttributes());
    assertEquals(m_Instances.numInstances(), result.numInstances());
    // the discretized attribute must be nominal
    assertTrue(result.attribute(m_AttIndex).isNominal());
  }

  public static Test suite() {
    return new TestSuite(PKIDiscretizeTest.class);
  }
View Full Code Here

  } else {
    pred = ce.getClassifier().classifyInstance(inst);
  }
  if (inst.classIndex() >= 0) {
    // need to check that the class is not missing
    if (inst.attribute(inst.classIndex()).isNominal()) {
      if (!inst.isMissing(inst.classIndex())) {
        if (m_dataPoint.length < 2) {
    m_dataPoint = new double[2];
    m_dataLegend.addElement("Accuracy");
    m_dataLegend.addElement("RMSE (prob)");
View Full Code Here

  public void testUseKononenko() {
    m_Filter = getFilter("3");
    ((Discretize)m_Filter).setUseKononenko(true);
    Instances result = useFilter();
    assertEquals(m_Instances.numAttributes(), result.numAttributes());
    assertEquals(Attribute.NOMINAL, result.attribute(2).type());
  }

  public static Test suite() {
    return new TestSuite(DiscretizeTest.class);
  }
View Full Code Here

  } while( projectedData == null );

  // Include the projected attributes in the attributes of the
  // transformed dataset
        for( int a = 0; a < projectedData.numAttributes() - 1; a++ ) {
          String newName = projectedData.attribute(a).name() + "_" + j;
          transformedAttributes.addElement( projectedData.attribute(a).copy(newName));
        }
      }
     
      transformedAttributes.addElement( data.classAttribute().copy() );
View Full Code Here

  // Include the projected attributes in the attributes of the
  // transformed dataset
        for( int a = 0; a < projectedData.numAttributes() - 1; a++ ) {
          String newName = projectedData.attribute(a).name() + "_" + j;
          transformedAttributes.addElement( projectedData.attribute(a).copy(newName));
        }
      }
     
      transformedAttributes.addElement( data.classAttribute().copy() );
      Instances transformedData = new Instances( "rotated-" + i + "-",
View Full Code Here

  if (theClass != -1) {
    if (theClass < 1 || theClass > train.numAttributes())
      throw new Exception("Class is out of range!");

    if (!train.attribute(theClass - 1).isNominal())
      throw new Exception("Class must be nominal!");
   
    train.setClassIndex(theClass - 1);
  }
      }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.