ValueError: Unknown label type: 'unknown' ValueError: Unknown label type: 'unknown' python python

ValueError: Unknown label type: 'unknown'


Your y is of type object, so sklearn cannot recognize its type. Add the line y=y.astype('int') right after the line y = train[:, 1].


Adding to Miriam ,I also got the similar error but in my case individual elements of y_pred was of type 'np.int32' and individual elements of y was of type 'int'.I solved it by doing:

for i,x in enumerate(y_pred):    y_pred[i]=x.astype('int')