Examples of numValues()


Examples of weka.core.Attribute.numValues()

    Enumeration attrEnum = getInputFormat().enumerateAttributes();
    while(attrEnum.hasMoreElements()) {
      Attribute attr = (Attribute) attrEnum.nextElement();
      if (!attr.equals(getInputFormat().classAttribute())) {
  if (attr.isNominal() || attr.isString()) {
    double[][] vdm = new double[attr.numValues()][attr.numValues()];
    vdmMap.put(attr, vdm);
    int[] featureValueCounts = new int[attr.numValues()];
    int[][] featureValueCountsByClass = new int[getInputFormat().classAttribute().numValues()][attr.numValues()];
    instanceEnum = getInputFormat().enumerateInstances();
    while(instanceEnum.hasMoreElements()) {
View Full Code Here

Examples of weka.core.Attribute.numValues()

      Attribute attr = (Attribute) attrEnum.nextElement();
      if (!attr.equals(getInputFormat().classAttribute())) {
  if (attr.isNominal() || attr.isString()) {
    double[][] vdm = new double[attr.numValues()][attr.numValues()];
    vdmMap.put(attr, vdm);
    int[] featureValueCounts = new int[attr.numValues()];
    int[][] featureValueCountsByClass = new int[getInputFormat().classAttribute().numValues()][attr.numValues()];
    instanceEnum = getInputFormat().enumerateInstances();
    while(instanceEnum.hasMoreElements()) {
      Instance instance = (Instance) instanceEnum.nextElement();
      int value = (int) instance.value(attr);
View Full Code Here

Examples of weka.core.Attribute.numValues()

      if (!attr.equals(getInputFormat().classAttribute())) {
  if (attr.isNominal() || attr.isString()) {
    double[][] vdm = new double[attr.numValues()][attr.numValues()];
    vdmMap.put(attr, vdm);
    int[] featureValueCounts = new int[attr.numValues()];
    int[][] featureValueCountsByClass = new int[getInputFormat().classAttribute().numValues()][attr.numValues()];
    instanceEnum = getInputFormat().enumerateInstances();
    while(instanceEnum.hasMoreElements()) {
      Instance instance = (Instance) instanceEnum.nextElement();
      int value = (int) instance.value(attr);
      int classValue = (int) instance.classValue();
View Full Code Here

Examples of weka.core.Attribute.numValues()

      int value = (int) instance.value(attr);
      int classValue = (int) instance.classValue();
      featureValueCounts[value]++;
      featureValueCountsByClass[classValue][value]++;
    }
    for (int valueIndex1 = 0; valueIndex1 < attr.numValues(); valueIndex1++) {
      for (int valueIndex2 = 0; valueIndex2 < attr.numValues(); valueIndex2++) {
        double sum = 0;
        for (int classValueIndex = 0; classValueIndex < getInputFormat().numClasses(); classValueIndex++) {
    double c1i = (double) featureValueCountsByClass[classValueIndex][valueIndex1];
    double c2i = (double) featureValueCountsByClass[classValueIndex][valueIndex2];
View Full Code Here

Examples of weka.core.Attribute.numValues()

      int classValue = (int) instance.classValue();
      featureValueCounts[value]++;
      featureValueCountsByClass[classValue][value]++;
    }
    for (int valueIndex1 = 0; valueIndex1 < attr.numValues(); valueIndex1++) {
      for (int valueIndex2 = 0; valueIndex2 < attr.numValues(); valueIndex2++) {
        double sum = 0;
        for (int classValueIndex = 0; classValueIndex < getInputFormat().numClasses(); classValueIndex++) {
    double c1i = (double) featureValueCountsByClass[classValueIndex][valueIndex1];
    double c2i = (double) featureValueCountsByClass[classValueIndex][valueIndex2];
    double c1 = (double) featureValueCounts[valueIndex1];
View Full Code Here

Examples of weka.core.Attribute.numValues()

      } else if (attr.isDate()) {
        double dif = nnArray[nn].value(attr) - instanceI.value(attr);
        double gap = rand.nextDouble();
        values[attr.index()] = (long) (instanceI.value(attr) + gap * dif);
      } else {
        int[] valueCounts = new int[attr.numValues()];
        int iVal = (int) instanceI.value(attr);
        valueCounts[iVal]++;
        for (int nnEx = 0; nnEx < nearestNeighbors; nnEx++) {
    int val = (int) nnArray[nnEx].value(attr);
    valueCounts[val]++;
View Full Code Here

Examples of weka.core.Instance.numValues()

      Assert.assertEquals("REL statechum compatibility score",testClassifier.attributesOfAnInstance[1].name());
    }
   
    {// pairB - another correct pair
      Instance instance = instEnum.nextElement();
      Assert.assertFalse(instance.classIsMissing());Assert.assertEquals(5,instance.numValues());
      Assert.assertFalse(instance.hasMissingValue());
      Assert.assertTrue(instance.classAttribute().isNominal());
      Assert.assertEquals(2,instance.classAttribute().numValues());// true/false
      Assert.assertEquals("true",instance.classAttribute().value((int) instance.value(instance.classAttribute())));
 
View Full Code Here

Examples of weka.core.Instance.numValues()

      Assert.assertEquals("REL statechum compatibility score",testClassifier.attributesOfAnInstance[1].name());
    }
   
    {// pairC - incorrect pair
      Instance instance = instEnum.nextElement();
      Assert.assertFalse(instance.classIsMissing());Assert.assertEquals(5,instance.numValues());
      Assert.assertFalse(instance.hasMissingValue());
      Assert.assertTrue(instance.classAttribute().isNominal());
      Assert.assertEquals(2,instance.classAttribute().numValues());// true/false
      Assert.assertEquals("false",instance.classAttribute().value((int) instance.value(instance.classAttribute())));
 
View Full Code Here

Examples of weka.core.Instance.numValues()

  public void testConstructEmptyInstance1()
  {
    WekaDataCollector classifier = new WekaDataCollector();
    classifier.initialise("TestCreateInstances2", 10, new ArrayList<PairRank>(),0);
    Instance instance = classifier.constructInstance(new int []{},false);
    Assert.assertFalse(instance.classIsMissing());Assert.assertEquals(1,instance.numValues());
    Assert.assertFalse(instance.hasMissingValue());
    Assert.assertTrue(instance.classAttribute().isNominal());
    Assert.assertEquals(2,instance.classAttribute().numValues());// true/false
    Assert.assertEquals("false",instance.classAttribute().value((int) instance.value(instance.classAttribute())));
    Assert.assertEquals("false",instance.stringValue(instance.classAttribute()));
View Full Code Here

Examples of weka.core.Instance.numValues()

      }
    });
    classifier.initialise("TestCreateInstances2", 0, assessors,0);
   
    Instance instance = classifier.constructInstance(new int []{1,0},true);
    Assert.assertFalse(instance.classIsMissing());Assert.assertEquals(3,instance.numValues());
    Assert.assertFalse(instance.hasMissingValue());
    Assert.assertTrue(instance.classAttribute().isNominal());
    Assert.assertEquals(2,instance.classAttribute().numValues());// true/false
    Assert.assertEquals("true",instance.classAttribute().value((int) instance.value(instance.classAttribute())));
    Assert.assertEquals(WekaDataCollector.ONE,instance.stringValue(classifier.attributesOfAnInstance[0]));
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.