MCPcopy Index your code
hub / github.com/EdwardRaff/JSAT / getNumericColumn

Method getNumericColumn

JSAT/src/jsat/DataSet.java:577–600  ·  view source on GitHub ↗

The data set can be seen as a NxM matrix, were each row is a data point, and each column the values for a particular variable. This method grabs all the numerical values for a 'column' and returns it as one vector. This vector can be altered and will not effect any of the values in the data set

(int i )

Source from the content-addressed store, hash-verified

575 * @return a Vector of length {@link #getSampleSize() }
576 */
577 public Vec getNumericColumn(int i )
578 {
579 if(i < 0 || i >= getNumNumericalVars())
580 throw new IndexOutOfBoundsException("There is no index for column " + i);
581
582 SoftReference<Vec> cachedRef = columnVecCache.get(i);
583 if (cachedRef != null)
584 {
585 Vec v = cachedRef.get();
586 if (v != null)
587 return v;
588 }
589 //no cache, so make it
590 DenseVector dv = new DenseVector(getSampleSize());
591 for (int j = 0; j < getSampleSize(); j++)
592 dv.set(j, getDataPoint(j).getNumericalValues().get(i));
593 Vec toRet;
594 if (getSparsityStats().getMean() < 0.6)
595 toRet = new SparseVector(dv);
596 else
597 toRet = dv;
598 columnVecCache.put(i, new SoftReference<Vec>(toRet));
599 return toRet;
600 }
601
602 /**
603 *

Callers 3

testTransform2_2Method · 0.80
testTransform2_3Method · 0.80

Calls 9

getNumNumericalVarsMethod · 0.95
getSampleSizeMethod · 0.95
setMethod · 0.95
getDataPointMethod · 0.95
getSparsityStatsMethod · 0.95
getNumericalValuesMethod · 0.80
getMethod · 0.45
getMeanMethod · 0.45
putMethod · 0.45

Tested by 3

testTransform2_2Method · 0.64
testTransform2_3Method · 0.64