Skip to content

ValueError: Invalid classes inferred from unique values of y. Expected: [0 1 2], got ['Negative' 'Neutral' 'Positive'] #1

Description

@AryanNandanwar

I'm encountering an error when trying to fit an XGBoost classifier to my data. I'm getting the following ValueError:

ValueError: Invalid classes inferred from unique values of y. Expected: [0 1 2], got ['Negative' 'Neutral' 'Positive']

I've attached the relevant code snippet for reference.
I believe this issue is due to the string labels in my target variable y. I've tried encoding them using LabelEncoder, but the error persists.
Could you please provide guidance on how to resolve this issue?
Thank you for your time and assistance.

xgb_cv=XGBClassifier()
xgb_cv.fit(cv_X_train,y_train)
pred_xgb_cv=xgb_cv.predict(cv_X_test)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions