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

Method getDataMatrix

JSAT/src/jsat/DataSet.java:709–735  ·  view source on GitHub ↗

Creates a matrix from the data set, where each row represent a data point, and each column is one of the numeric example from the data set. This matrix can be altered and will not effect any of the values in the data set. @return a matrix of the data points.

()

Source from the content-addressed store, hash-verified

707 * @return a matrix of the data points.
708 */
709 public Matrix getDataMatrix()
710 {
711 if(this.getSampleSize() > 0 && this.getDataPoint(0).getNumericalValues().isSparse())
712 {
713 SparseVector[] vecs = new SparseVector[this.getSampleSize()];
714 for(int i = 0; i < getSampleSize(); i++)
715 {
716 Vec row = getDataPoint(i).getNumericalValues();
717 vecs[i] = new SparseVector(row);
718 }
719
720 return new SparseMatrix(vecs);
721 }
722 else
723 {
724 DenseMatrix matrix = new DenseMatrix(this.getSampleSize(), this.getNumNumericalVars());
725
726 for(int i = 0; i < getSampleSize(); i++)
727 {
728 Vec row = getDataPoint(i).getNumericalValues();
729 for(int j = 0; j < row.length(); j++)
730 matrix.set(i, j, row.get(j));
731 }
732
733 return matrix;
734 }
735 }
736
737 /**
738 * Creates a matrix backed by the data set, where each row is a data point

Callers 2

clusterMethod · 0.80
fitMethod · 0.80

Calls 8

getSampleSizeMethod · 0.95
getDataPointMethod · 0.95
getNumNumericalVarsMethod · 0.95
lengthMethod · 0.95
setMethod · 0.95
getMethod · 0.95
getNumericalValuesMethod · 0.80
isSparseMethod · 0.45

Tested by

no test coverage detected