I have a dataset for different types of plants, and I divided each species into another np.array.
When trying to generate Gaussian models from these types, I had to calculate the means and covariance matrices for each other label.
The problem is this: when used np.cov()in one of the labels, the function raises the error "object float" does not have the attribute "shape", and I can’t understand where this problem came from. The exact line of code I'm using is as follows:
covx = np.cov(label0, rowvar=False)
Where label0is the numpy ndarray form (50.3), where the columns represent different variables, and each row represents a different observation.
Accurate error tracing:
AttributeError Traceback (most recent call last)
<ipython-input-81-277aa1d02ff0> in <module>()
2
3
C:\Users\Matheus\Anaconda3\lib\site-packages\numpy\lib\function_base.py in cov(m, y, rowvar, bias, ddof, fweights, aweights)
3062 w *= aweights
3063
-> 3064 avg, w_sum = average(X, axis=1, weights=w, returned=True)
3065 w_sum = w_sum[0]
3066
C:\Users\Matheus\Anaconda3\lib\site-packages\numpy\lib\function_base.py in average(a, axis, weights, returned)
1143
1144 if returned:
-> 1145 if scl.shape != avg.shape:
1146 scl = np.broadcast_to(scl, avg.shape).copy()
1147 return avg, scl
AttributeError: 'float' object has no attribute 'shape'
, ?