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
()
| 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. |
no test coverage detected