Closed asentis closed 7 years ago
The function is expecting two TrainingClass
objects as its arguments. It looks like you are passing an ndarray
instead. You can't compute the Bhattacharyya distance with just two arrays because it requires a mean and covariance for each class.
Note that the function doesn't really need the arguments to be TrainingClass
objects - just any two objects that themselves have a stats
attribute of type GaussianStats
. So you could cheat and do something like
c1 = spy.calc_stats(array1)
c1.stats = c1
c2 = spy.calc_stats(array2)
c2.stats = c2
m = spy.bdist(c1, c2)
Thanks for the prompt reply! I missed that requirement in the documentation.
Separately, my datasets are of size m x 2 and n x 2. Is it required that the TraningClass object inputs be of the same dimensions?
No, you only need to have the same number of bands for each data set.
If I understand correctly, my datasets should both have number of bands = 1. However, I receive the following error when using your above code:
m = a.stats.mean - b.stats.mean
ValueError: operands could not be broadcast together with shapes (36,) (32,)
I have confirmed that my numpy.ndarrays have shape (36,2) and (32,2).
It doesn't make sense to compute the Bhattacharyya distance for single-band data because it is only applicable to multivariate distributions. The data for which you are computing statistics should have shape (nrows, ncols, nbands)
where nrows
or ncols
could be 1 but nbands
must be greater than 1.
Hello,
I receive the following attribute error when attempting to use the bdist function:
Is there a solution for this? Thanks very much.