/** * Merges this instance with the given instance and returns the result. * Dataset is set to null. * * @param inst the instance to be merged with this one * @return the merged instances */ @Override public Instance mergeInstance(Instance inst) { double[] values = new double[numValues() + inst.numValues()]; int[] indices = new int[numValues() + inst.numValues()]; int m = 0; for (int j = 0; j < numValues(); j++, m++) { values[m] = valueSparse(j); indices[m] = index(j); } for (int j = 0; j < inst.numValues(); j++, m++) { values[m] = inst.valueSparse(j); indices[m] = numAttributes() + inst.index(j); } return new SparseInstance(1.0, values, indices, numAttributes() + inst.numAttributes()); }
/** * Merges this instance with the given instance and returns the result. * Dataset is set to null. * * @param inst the instance to be merged with this one * @return the merged instances */ @Override public Instance mergeInstance(Instance inst) { double[] values = new double[numValues() + inst.numValues()]; int[] indices = new int[numValues() + inst.numValues()]; int m = 0; for (int j = 0; j < numValues(); j++, m++) { values[m] = valueSparse(j); indices[m] = index(j); } for (int j = 0; j < inst.numValues(); j++, m++) { values[m] = inst.valueSparse(j); indices[m] = numAttributes() + inst.index(j); } return new SparseInstance(1.0, values, indices, numAttributes() + inst.numAttributes()); }
for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(","); while (inst.numValues() > 0) { inst.setValueSparse(0, 0); for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(","); inst.setValue(i, 1); for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(",");
for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(","); while (inst.numValues() > 0) { inst.setValueSparse(0, 0); for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(","); inst.setValue(i, 1); for (int i = 0; i < inst.numValues(); i++) { if (i > 0) { System.out.print(",");
if (temp == 0) { // handle the special case temp==0. see footnote 1 double sum = 0; for (int k = 0; k < m_histBarClassCounts[0].numValues(); k++) { sum += m_histBarClassCounts[0].valueSparse(k); for (int k = 0; k < m_histBarClassCounts[temp].numValues(); k++) { sum += m_histBarClassCounts[temp].valueSparse(k);
if (temp == 0) { // handle the special case temp==0. see footnote 1 double sum = 0; for (int k = 0; k < m_histBarClassCounts[0].numValues(); k++) { sum += m_histBarClassCounts[0].valueSparse(k); for (int k = 0; k < m_histBarClassCounts[temp].numValues(); k++) { sum += m_histBarClassCounts[temp].valueSparse(k);
for (int j = 0; j < m_histBarClassCount.numValues(); j++) { y = (int) (y - Math.round(m_histBarClassCount.valueSparse(j)
for (int j = 0; j < m_histBarClassCount.numValues(); j++) { y = (int) (y - Math.round(m_histBarClassCount.valueSparse(j)
public net.sf.javaml.core.Instance instanceFromWeka(Instance inst) { net.sf.javaml.core.Instance out; if (inst instanceof SparseInstance) { out = new net.sf.javaml.core.SparseInstance(); SparseInstance tmp = (SparseInstance) inst; for (int i = 0; i < tmp.numValues(); i++) { int index = inst.index(i); double value = inst.value(index); out.put(index, value); } } else { double[] vals; if (inst.classIsMissing()) vals = inst.toDoubleArray(); else { vals = new double[inst.numAttributes() - 1]; double[] tmp = inst.toDoubleArray(); System.arraycopy(tmp, 0, vals, 0, inst.classIndex()); System.arraycopy(tmp, inst.classIndex() + 1, vals, inst.classIndex(), vals.length - inst.classIndex()); } out = new DenseInstance(vals); } if (!inst.classIsMissing()) { out.setClassValue(wData.classAttribute().value((int)inst.classValue())); } return out; }