Examples of SparseInstance


Examples of weka.core.SparseInstance

    data[data.length - 1] = result.classAttribute().indexOfValue("-1");
  else
    throw new IllegalStateException("Class is not binary!");
      }
     
      result.add(new SparseInstance(1, data));
    }

    try {
      // close the stream
      m_sourceReader.close();
View Full Code Here

Examples of weka.core.SparseInstance

        vals[i] = dest.value(i);
      }
    }
    Instance inst = null;
    if (dest instanceof SparseInstance) {
      inst = new SparseInstance(dest.weight(), vals);
    } else {
      inst = new Instance(dest.weight(), vals);
    }
    inst.setDataset(dest.dataset());
    return inst;
View Full Code Here

Examples of weka.core.SparseInstance

    indices[num] = instance.index(j);
    num++;
  }
      }
      if (num == instance.numValues()) {
  inst = new SparseInstance(instance.weight(), vals, indices,
                                  instance.numAttributes());
      } else {
  double []tempVals = new double[num];
  int []tempInd = new int[num];
  System.arraycopy(vals, 0, tempVals, 0, num);
  System.arraycopy(indices, 0, tempInd, 0, num);
  inst = new SparseInstance(instance.weight(), tempVals, tempInd,
                                  instance.numAttributes());
      }
    } else {
      double []vals = new double[getInputFormat().numAttributes()];
      for (int j = 0; j < instance.numAttributes(); j++) {
View Full Code Here

Examples of weka.core.SparseInstance

  }
      }
    }
    Instance inst = null;
    if (instance instanceof SparseInstance) {
      inst = new SparseInstance(instance.weight(), vals);
    } else {
      inst = new Instance(instance.weight(), vals);
    }
    inst.setDataset(instance.dataset());
    push(inst);
View Full Code Here

Examples of weka.core.SparseInstance

     
      double[] tempVals = new double[ind];
      int[] tempInd = new int[ind];
      System.arraycopy(newVals, 0, tempVals, 0, ind);
      System.arraycopy(newIndices, 0, tempInd, 0, ind);
      inst = new SparseInstance(instance.weight(), tempVals, tempInd,
                                instance.numAttributes());
    } else {
      double[] vals = instance.toDoubleArray();
      for (int j = 0; j < getInputFormat().numAttributes(); j++) {
  if (instance.attribute(j).isNumeric() &&
View Full Code Here

Examples of weka.core.SparseInstance

      }
    }

    Instance inst = null;
    if (instance instanceof SparseInstance) {
      inst = new SparseInstance(instance.weight(), vals);
    } else {
      inst = new Instance(instance.weight(), vals);
    }
    inst.setDataset(getOutputFormat());
    copyValues(inst, false, instance.dataset(), getOutputFormat());
View Full Code Here

Examples of weka.core.SparseInstance

      int current = m_SelectedAttributes[i];
      vals[i + j] = instance.value(current);
    }
    Instance inst = null;
    if (instance instanceof SparseInstance) {
      inst = new SparseInstance(instance.weight(), vals);
    } else {
      inst = new Instance(instance.weight(), vals);
    }

    inst.setDataset(getOutputFormat());
View Full Code Here

Examples of weka.core.SparseInstance

    }
    if (m_NewBatch) {
      resetQueue();
      m_NewBatch = false;
    }
    Instance inst = new SparseInstance(instance);
    inst.setDataset(instance.dataset());
    push(inst);
    return true;
  }
View Full Code Here

Examples of weka.core.SparseInstance

        newValues[m_outputNumAttributes - 1] = currentInstance.classValue();
      }
      //create new instance with recorded values and add to output dataset
      Instance newInstance;
      if (currentInstance instanceof SparseInstance) {
        newInstance = new SparseInstance(currentInstance.weight(), newValues);
      } else {
        newInstance = new Instance(currentInstance.weight(), newValues);
      }
      output.add(newInstance);
    }
View Full Code Here

Examples of weka.core.SparseInstance

      newValues[i] = instanceVector.get(0, i);
    }
   
    // return newly transformed instance
    if (instance instanceof SparseInstance) {
      return new SparseInstance(instance.weight(), newValues);
    } else {
      return new Instance(instance.weight(), newValues);
    }
  }
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.