Custom Python Model XGBoost Training Error
![Brenna](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar22.png)
Brenna
Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Registered Posts: 3 ✭✭✭
Hello,
I trained a Custom Python model with the XGBoost code sample using the built-in env but got an error, "Coefficients are not defined for Booster type gbtree". Please find details in the attached images.
Do I need to install any package or update anything?
Thanks!
Operating system used: Windows 10
Tagged:
Answers
-
Hi,
This is indeed a bug that is planned to be fixed in the next DSS version. In the meantime, you can use this code sample as a workaround
from sklearn.base import BaseEstimator import xgboost as xgb class DSSXGBRegressor(BaseEstimator): def __init__(self, **kwargs): self.clf = xgb.XGBRegressor(**kwargs) def fit(self, X, y): self.clf.fit(X,y) def predict(self, X): return self.clf.predict(X) def get_params(self, deep=False): return self.clf.get_params(deep) clf = DSSXGBRegressor(booster='gblinear', gamma=0, max_depth=6, min_child_weight=1)
-
Brenna Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Registered Posts: 3 ✭✭✭
Hi Alex,
Thank you for your answer. I copied and pasted your code sample but got a PicklingError:
PicklingError: Can't pickle <class 'DSSXGBRegressor'>: it's not found as __builtin__.DSSXGBRegressor
Best,
Boren