ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1], got [-1 1]

Course Name: Advanced Momentum Trading: Machine Learning Strategies, Section No: 12, Unit No: 12, Unit type: Notebook

I got error in line: model.fit(X_train, y_train, eval_metric='logloss')

Error is ValueError: Invalid classes inferred from unique values of `y`. Expected: [0 1], got [-1 1]

I use xgboost-2.0.3

Please help to fix this

 

 

 

Hi Dav,



To fix this, you can install XGBoost version 1.4.1 using the following command and re-run the notebook.

!pip install xgboost==1.4.1

 Please let us know if you are still facing any issues. 

I have another error: when running: model.fit(X_train, y_train, eval_metric='logloss')

ImportError: cannot import name 'Int64Index' from 'pandas'

I use pandas 2.2.0 and python 3.10.13


Hi Dav,



To fix this, you can install pandas version 1.2.4 using the following command and re-run the notebook.

!pip install pandas==1.2.4