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

Method getSparsityStats

JSAT/src/jsat/DataSet.java:799–812  ·  view source on GitHub ↗

Returns statistics on the sparsity of the vectors in this data set. Vectors that are not considered sparse will be treated as completely dense, even if zero values exist in the data. @return an object containing the statistics of the vector sparsity

()

Source from the content-addressed store, hash-verified

797 * @return an object containing the statistics of the vector sparsity
798 */
799 public OnLineStatistics getSparsityStats()
800 {
801 OnLineStatistics stats = new OnLineStatistics();
802 for(int i = 0; i < getSampleSize(); i++)
803 {
804 Vec v = getDataPoint(i).getNumericalValues();
805 if(v.isSparse())
806 stats.add(v.nnz() / (double)v.length());
807 else
808 stats.add(1.0);
809 }
810
811 return stats;
812 }
813
814 /**
815 * This method returns the weight of each data point in a single Vector.

Callers 2

getNumericColumnMethod · 0.95
getNumericColumnsMethod · 0.95

Calls 7

getSampleSizeMethod · 0.95
getDataPointMethod · 0.95
isSparseMethod · 0.95
addMethod · 0.95
nnzMethod · 0.95
lengthMethod · 0.95
getNumericalValuesMethod · 0.80

Tested by

no test coverage detected