• Register
Welcome to Kodlogs, programming questions and answer website.
0 votes


I am having issues with following code, can you help me to sort out this issue:

x = mat

y = pd.factorize(new_df[‘lblCode’].values)[0].reshape(-1, 1) # label

varx, x_test, vary, y_test = train_test_split(x, y, testS=0.2, raState=42)

 model = KNeighborsClassifier(n_neighbors = 12)

model.fit(varx, vary)

prediction = model.predict_proba(x_test)

print(accuracy_score(y_test, prediction))

main:11: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().

Traceback (most recent call last):


File “”, line 13, in 

print(accuracy_score(y_test, prediction))


File “/home/gigiux/.local/lib/python3.6/site-packages/sklearn/metrics/classification.py”, line 176, in accuracy_score

y_type, y_true, y_pred = _check_targets(y_true, y_pred)


File “/home/gigiux/.local/lib/python3.6/site-packages/sklearn/metrics/classification.py”, line 81, in _check_targets

“and {1} targets”.format(type_true, type_pred))


ValueError: Classification metrics can’t handle a mix of multiclass and continuous-multioutput targets

by (1.6k points)  
edited by

Your answer

Please note that all answers are moderated and will be deleted if they are:

>Not relavant to the programming or IT related
>Advertising campaigns or links to other sites
>Abusive content.

Kindly do not waste your time by posting non relevant content on Kodlogs.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.