I would like to use the package XGboost in Python, however, when I want to create the model using numpy data and label with the same shape.
Following this:
If I run the following code, should work:
xg_reg = xgb.XGBRegressor(objective ='reg:linear', colsample_bytree = 0.3, learning_rate = 0.1,
max_depth = 5, alpha = 10, n_estimators = 10)
xg_reg.fit(xgb.DMatrix(X),y)
I get this error:
TypeError: Not supported type for data.<class 'xgboost.core.DMatrix'>
Both X and y has this content:
array([[41.4049364, 2.177356 ],
[41.4049656, 2.1773926],
[41.4049938, 2.1774287],
[41.4050204, 2.1774638],
[41.4050453, 2.1774975],
[41.4050682, 2.1775296],
[41.4050895, 2.1775597],
[41.4051093, 2.1775874],
[41.4051278, 2.1776125]])
Updated:
If using
xg_reg.fit(X,y)
Then:
~\anaconda3\lib\site-packages\xgboost\data.py in _validate_meta_shape(data)
615 def _validate_meta_shape(data):
616 if hasattr(data, 'shape'):
--> 617 assert len(data.shape) == 1 or (
618 len(data.shape) == 2 and
619 (data.shape[1] == 0 or data.shape[1] == 1))
AssertionError:
Any clue?