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)
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 usingLabelEncoder, 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)