hi every one.I want to calculate the sparsity of data by HTM spatial pooler algorithm (I mean, I want to calculate the input sparsity rate as well as the output sparsity rate of the algorithm and then get the input sparsity ratio to output). For this purpose, I used the number of non-zero sparsity. I also found that the Gini index is also suitable for calculating sparsity, So I decided to use this index to calculate the sparsity of the spatial pooler algorithm. in the Gini index , we have to arrange the vector input / output numbers in order from small to large according to the following formula
But we know that the output of the spatial pooler algorithm is a vector of 0 and 1.How do I calculate the Gini index?Is this possible?
Please introduce another suitable information theory index for calculating sparsity
Usually sparsity is calculated as the fraction of the vector which is 1’s.
For example if you have the vector: “110000” then the sparsity is 2/6 = 33%.
In a spatial pooler, the output sparsity should be constant (assuming that there are a sufficient number of active inputs).
I don’t know much about the gini index. According to Wikipedia: The Gini coefficient measures the inequality among values of a frequency distribution.
For this task you can measure the binary entropy of the representations. You will also want to divide that entropy by the maximum possible entropy for your system to get a value in the range [0, 1].
If you’re using htm.core then the class htm.bindings.sdr.Metrics will measure and report the activation frequency distribution and binary entropy.
Thanks for your guidance, Could you please explain more about this, how the binary entropy of the representations is the same as the Gini index(Gini coefficient)?
i use nupic-master, Please tell me How can I calculate the Gini coefficient in nupic-master code?