AttributeError: 'tuple' object has no attribute 'reshape'

1

Error:

AttributeError: 'tuple' object has no attribute 'reshape'

Code:

xx, yy = np.meshgrid(np.arange(x_min, x_max, h),np.arange(y_min, y_max, h))
y_pred = y_pred.reshape(xx.shape)
plt.figure()

In y_pred = y_pred.reshape(xx.shape) there is this error, what to do?

    
asked by anonymous 02.08.2018 / 15:11

1 answer

2

This is because .reshape is a method only of the NumPy array. So for some reason you stored algorithm predictions inside a tuple instead of an numpy array. you can do the following and try again.

y_pred = np.array(y_pred)

To check the type of object you are dealing with you can use for example:

type(y_pred)

In case of any problems, notice how you are doing the prediction with the algorithm.

    
02.08.2018 / 15:34