Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xgboost TypeError: can not initialize DMatrix from DataFrame

Tags:

xgboost

I am getting the below error when creating a DMatrix from a data in python.

TypeError: can not initialize DMatrix from DataFrame
Exception AttributeError: "'DMatrix' object has no attribute 'handle'" in <bound method DMatrix.__del__ ofrix object at 0x584d210>> ignored

like image 550
Gagan Avatar asked Nov 08 '22 20:11

Gagan


1 Answers

Without accompanying code my best guess is you are passing the pandas data-frame directly, instead you need to pass numpy representation of the dataframe ie., pandas.DataFrame.values as below

X_train = pd.read_csv("train.csv")
y_train = X_train['label']
X_train.drop(['label'],axis=1,inplace=True)
final_GBM.fit(X_train.values,y_train.values)
like image 102
Jeevan Avatar answered Jan 04 '23 01:01

Jeevan