close

[Solved] ValueError: Unknown label type: ‘unknown’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ValueError: Unknown label type: ‘unknown’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ValueError: Unknown label type: ‘unknown’ Error Occurs?

Today I get the following error ValueError: Unknown label type: ‘unknown’ in python.

How To Solve ValueError: Unknown label type: ‘unknown’ Error ?

  1. How To Solve ValueError: Unknown label type: 'unknown' Error ?

    To Solve ValueError: Unknown label type: 'unknown' Error 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].

  2. ValueError: Unknown label type: 'unknown'

    To Solve ValueError: Unknown label type: 'unknown' Error 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].

Solution 1

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].

Solution 2

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')

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read