stanfordmlgroup / ngboost

Natural Gradient Boosting for Probabilistic Prediction
Apache License 2.0
1.64k stars 215 forks source link

AttributeError: 'NGBClassifier' object has no attribute 'classes_' #323

Closed SamHosico closed 1 year ago

SamHosico commented 1 year ago

when I use ngboost and sklearn, ngboost return a error: AttributeError: 'NGBClassifier' object has no attribute 'classes' I have checked the lightGBM, it has the 'classes', so I dont know how can I solve this problem, I need some help. my code is as follows:

model = NGBClassifier(n_estimators=int(params['n_estimators']) , learning_rate=params['learning_rate'] , minibatch_frac=params['minibatch_frac'] , col_sample=params['col_sample'] , Dist=Bernoulli , verbose=False , random_state=42) cv = StratifiedKFold(n_splits=10, shuffle=True, random_state=42) score = -cross_val_score(model, X_train, y_train.ravel(), cv=cv, scoring='roc_auc_ovo_weighted', error_score='raise').mean()### ###

ryan-wolbeck commented 1 year ago

Can you include what version you are using and provide a full example code with imports and loading a sample data like the Boston data?

SamHosico commented 1 year ago

Can you include what version you are using and provide a full example code with imports and loading a sample data like the Boston data? Thanks for your reply! I have rewritten a function to replace cross validation in sklearn using the 'roc_auc' to train my model, I have achieved the expected results.