Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HGBC with categorical_crossentropy fails silently on binary classification #14858

@adrinjalali

Description

@adrinjalali
import numpy as np
from sklearn.experimental import enable_hist_gradient_boosting
from sklearn.ensemble import HistGradientBoostingClassifier

X = [[1, 0],
     [1, 0],
     [1, 0],
     [0, 1],
     [1, 1]]
y = [1, 1, 1, 0, 1]
gb = HistGradientBoostingClassifier(loss='categorical_crossentropy',
                                    min_samples_leaf=1)
gb.fit(X, y)
print(gb.predict([[1, 0]]))
print(gb.predict([[0, 1]]))

gives:

[0]
[0]

And binary_crossentropy works fine. categorical_crossentropy should either generalize or raise an error on binary classification.

Ping @NicolasHug @ogrisel

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions