Open jasperalbers opened 3 years ago
Try setting bins
to an integer by adding a bins = int(bins)
line right after line 42 of kl_divergence.py.
Your suggestion makes the code not run into the error! However, the resulting scores are not numbers:
In: print(judge)
Out:
PyNN Nest
PyNN \n\nKullback-Leibler-Divergence\n\tdat... \n\nKullback-Leibler-Divergence\n\tdat...
Nest \n\nKullback-Leibler-Divergence\n\tdat... \n\nKullback-Leibler-Divergence\n\tdat...
The judge function returns a score object (or for multiple tests a score collection object). Printing the object invokes its __str__
attribute which is for the networkunit score types a string describing the score. To only get the numerical score you can do print(score.score)
.
Actually I think printing a score object itself should just print the .score
attribute already: https://github.com/scidash/sciunit/blob/master/sciunit/scores/base.py#L288. But you have a score matrix (models x models) which is like a pandas dataframe. Just enter judge
directly on a line and you will get a rich html representation of it (in a Jupyter notebook) or in a console you may still get something like what you see above. Probably I should consider overriding the default Pandas representation in the console with one that contains the .score
attribute for each score in the matrix.
judge.score
does return the desired matrix of scores, thanks!
I am trying to use the
kl_divergence
score to compare distributions from two sets of spiking data from two simulators (NEST and PyNN). Since the model I am investigating has multiple distinct populations, I want to compare the distributions of these populations separately. For this, I am using thejoint_test
example together with alabel_test
that checks for spiketrains to be from the same population and a conventional test (e.g. firing rate, cv isi, ...). However, this is currently not possible, even though thejoint_test
only produces a single score and not multiple ones, while usingwasserstein_distance
works. A first attempt at rectifying this was adding code that ensures that thelayer_prediction
andlayer_observation
are 1d (see below), but this did resulted in the same error which I append at the end.Here is a reduced code example (sorry, still quite long), provided that one has some spiking data at hand that can be separated according to their annotation:
Error thrown: