Skip to content

'NGBClassifier' object has no attribute 'classes_' #350

Open
@SamHosico

Description

@SamHosico

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:

from matplotlib import pyplot as plt
from sklearn.metrics import plot_roc_curve
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from ngboost import NGBClassifier
import numpy as np

model = NGBClassifier(n_estimators=10 # 922
, learning_rate=0.05
, natural_gradient=False
, random_state=42
, verbose=False)
data = load_breast_cancer()
X = data.data
y = data.target
y = y.astype(np.int32)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
plot_roc_curve(model.fit(X_train, y_train), X_test, y_test, name='XX', pos_label=1, linewidth=2)
plt.show()

And the versions of third-party libraries are as follows:
ngboost 0.5.1
matplotlib 3.5.3
scikit-learn 1.1.3

I'm sorry I didn't reply to your source code request at the time @ryan-wolbeck, thanks for your attention at that time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions