Package weka.core

Examples of weka.core.Instances.numInstances()


      Instances costBenefitI = new Instances("Cost/Benefit Curve", fv, 100);
     
      // process the performance data to make this curve
      Instances performanceI = m_masterPlot.getPlotInstances();
     
      for (int i = 0; i < performanceI.numInstances(); i++) {
        Instance current = performanceI.instance(i);
       
        double[] vals = new double[2];
        vals[0] = current.value(10); // sample size
        vals[1] = (current.value(0) * tpCost
 
View Full Code Here


      m_splitThread = new Thread() {
    public void run() {
      try {
        dataSet.randomize(new Random(m_randomSeed));
        int trainSize =
                (int)Math.round(dataSet.numInstances() * m_trainPercentage / 100);
        int testSize = dataSet.numInstances() - trainSize;
     
        Instances train = new Instances(dataSet, 0, trainSize);
        Instances test = new Instances(dataSet, trainSize, testSize);
     
View Full Code Here

    public void run() {
      try {
        dataSet.randomize(new Random(m_randomSeed));
        int trainSize =
                (int)Math.round(dataSet.numInstances() * m_trainPercentage / 100);
        int testSize = dataSet.numInstances() - trainSize;
     
        Instances train = new Instances(dataSet, 0, trainSize);
        Instances test = new Instances(dataSet, trainSize, testSize);
     
        TrainingSetEvent tse =
View Full Code Here

    Random rand = new Random(getRandomSeed());

    // find the set of extra indices to use if the percentage is not evenly divisible by 100
    List extraIndices = new LinkedList();
    double percentageRemainder = (getPercentage() / 100) - Math.floor(getPercentage() / 100.0);
    int extraIndicesCount = (int) (percentageRemainder * sample.numInstances());
    if (extraIndicesCount >= 1) {
      for (int i = 0; i < sample.numInstances(); i++) {
  extraIndices.add(i);
      }
    }
View Full Code Here

    // find the set of extra indices to use if the percentage is not evenly divisible by 100
    List extraIndices = new LinkedList();
    double percentageRemainder = (getPercentage() / 100) - Math.floor(getPercentage() / 100.0);
    int extraIndicesCount = (int) (percentageRemainder * sample.numInstances());
    if (extraIndicesCount >= 1) {
      for (int i = 0; i < sample.numInstances(); i++) {
  extraIndices.add(i);
      }
    }
    Collections.shuffle(extraIndices, rand);
    extraIndices = extraIndices.subList(0, extraIndicesCount);
View Full Code Here

    Set extraIndexSet = new HashSet(extraIndices);

    // the main loop to handle computing nearest neighbors and generating SMOTE
    // examples from each instance in the original minority class data
    Instance[] nnArray = new Instance[nearestNeighbors];
    for (int i = 0; i < sample.numInstances(); i++) {
      Instance instanceI = sample.instance(i);
      // find k nearest neighbors for each instance
      List distanceToInstance = new LinkedList();
      for (int j = 0; j < sample.numInstances(); j++) {
  Instance instanceJ = sample.instance(j);
View Full Code Here

    Instance[] nnArray = new Instance[nearestNeighbors];
    for (int i = 0; i < sample.numInstances(); i++) {
      Instance instanceI = sample.instance(i);
      // find k nearest neighbors for each instance
      List distanceToInstance = new LinkedList();
      for (int j = 0; j < sample.numInstances(); j++) {
  Instance instanceJ = sample.instance(j);
  if (i != j) {
    double distance = 0;
    attrEnum = getInputFormat().enumerateAttributes();
    while(attrEnum.hasMoreElements()) {
View Full Code Here

  public void testTypical() {
    Instances result = useFilter();
    // Number of attributes changes
    assertEquals(m_Instances.numAttributes() + 3, result.numAttributes());
    // Number of instances shouldn't change
    assertEquals(m_Instances.numInstances(),  result.numInstances());
    // Eibe can enhance this to check the binarizing is correct.
  }


  public static Test suite() {
View Full Code Here

      instances = getInputFormat();
    }
   
    flushInput();

    for (int i = 0; i < instances.numInstances(); i++) {
      push(instances.instance(i));
    }

    m_NewBatch = true;
    m_FirstBatchDone = true;
View Full Code Here

  public void testNumeric() {
    ((RemoveWithValues)m_Filter).setAttributeIndex("3");
    Instances result = useFilter();
    assertEquals(m_Instances.numAttributes(), result.numAttributes());
    assertEquals("Default split point matches values less than 0",
                 0,  result.numInstances());

    ((RemoveWithValues)m_Filter).setSplitPoint(3);
    result = useFilter();
    assertEquals(m_Instances.numAttributes(), result.numAttributes());
    assertTrue(m_Instances.numInstances() > result.numInstances());
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.