The xgboost model training failed -
This is the error info:
ValueError: DataFrame.dtypes for data must be int, float, bool or categorical. When
categorical type is supplied, DMatrix parameter
enable_categorical must be set to True.mother_age, plurality, gestation_weeks
As you can see, I checked the data type in the data frame and they are all numerical, based on the error info I tried to set enable_categorical=True, but still doesn’t work.

I don’t know where is the issue. could you help me? Thanks.

It might be possible that even though they look numerical they might be strings some of them, so you should check the type of the features and change to int or float if needed.

Hi @Josh_Chen,

Have you check the data for null values or other anomalies. Please try running this codes before training the model

df = data.dropna()
df = shuffle(data, random_state=2)

Let me know if it helps,

To show all the code I have run so far, I put them in one cell, as you can see, I’m using all shared code snippets from the GitHub repo, but still doesn’t work. so I have to check the type of features and make sure it’s numerical by myself, working on it.

Fixed it by casting all 4 data columns to an int dtype.
@Th_o_Vy_Le_Nguy_n @gent.spah Thanks.