Package weka.core

Examples of weka.core.Instance.copy()


        Entry<Integer, Double> tempEntry;
        Instance iExample;
        int i = 0;
        Instance originalCopy = getNewInstance(numAtts);
        for (LinkedHashMap<Integer, Double> currentSample : trainingSamples) {
            iExample = (Instance) originalCopy.copy();
            iExample.setDataset(trainingSet);
            currentIt = currentSample.entrySet().iterator();
            while (currentIt.hasNext()) {
                tempEntry = currentIt.next();
                iExample.setValue(tempEntry.getKey(), tempEntry.getValue());
View Full Code Here


    // also push all dataset instances
    Instances sample = getInputFormat().stringFreeStructure();
    Enumeration instanceEnum = getInputFormat().enumerateInstances();
    while(instanceEnum.hasMoreElements()) {
      Instance instance = (Instance) instanceEnum.nextElement();
      push((Instance) instance.copy());
      if ((int) instance.classValue() == minIndex) {
  sample.add(instance);
      }
    }
View Full Code Here

    int subset;
    for (int i = 0; i < trainInstances.numInstances(); i++) {
      instance = trainInstances.instance(i);
      subset = m_c45S.whichSubset(instance);
      if (subset > -1) {
  trainingSets[subset].add((Instance)instance.copy());
      } else {
  double [] weights = m_c45S.weights(instance);
  for (int j = 0; j < m_complexityIndex; j++) {
    try {
      Instance temp = (Instance) instance.copy();
View Full Code Here

    // populate the subsets
    for (int i = 0; i < trainInstances.numInstances(); i++) {
      Instance instance = trainInstances.instance(i);
      subset = m_c45S.whichSubset(instance);
      if (subset != -1) {
  trainingSets[subset].add((Instance)instance.copy());
      } else {
  double [] weights = m_c45S.weights(instance);
  for (int j = 0; j < m_complexityIndex; j++) {
    Instance temp = (Instance)instance.copy();
    if (weights.length == m_complexityIndex) {
View Full Code Here

    // do while not added all
    do {
      // add all for one value combination
      for (int k = 0; k < numEach; k++) {
        format.add(example);
        example = (Instance) example.copy();
        added++;
      }
      if (rest > 0) {
        format.add(example);
        example = (Instance) example.copy();
View Full Code Here

        example = (Instance) example.copy();
        added++;
      }
      if (rest > 0) {
        format.add(example);
        example = (Instance) example.copy();
        added++;
        rest--;
      }

      if (added >= numInstances) break;
View Full Code Here

    // also push all dataset instances
    Instances sample = getInputFormat().stringFreeStructure();
    Enumeration instanceEnum = getInputFormat().enumerateInstances();
    while( instanceEnum.hasMoreElements() ) {
      Instance instance = (Instance) instanceEnum.nextElement();
      push( (Instance) instance.copy() );
      if( (int) instance.classValue() == minIndex ) {
        sample.add( instance );
      }
    }
View Full Code Here

      if(dist > maxDist) {
        maxDist = dist; furthest1 = temp;
      }
    }
    maxDist = Double.NEGATIVE_INFINITY;
    furthest1 = (Instance)furthest1.copy();
    for(int i=0; i < node.m_NumInstances; i++) {
      temp = m_Instances.instance(m_Instlist[i+node.m_Start]);
      distList[i] = m_DistanceFunction.distance(furthest1, temp,
                                                Double.POSITIVE_INFINITY);
      if(distList[i] > maxDist) {
View Full Code Here

    // do while not added all
    do {
      // add all for one value combination
      for (int k = 0; k < numEach; k++) {
        format.add(example);
        example = (Instance) example.copy();
        added++;
      }
      if (rest > 0) {
        format.add(example);
        example = (Instance) example.copy();
View Full Code Here

        example = (Instance) example.copy();
        added++;
      }
      if (rest > 0) {
        format.add(example);
        example = (Instance) example.copy();
        added++;
        rest--;
      }

      if (added >= numInstances) break;
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.