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 )
| 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 | * |