[Python] XGBoost does not predict properly on input that's equal to traning data

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    Why this quite simple example of XGBoost ML produces all-nulls even on input, that's equivalent to training data? This looks like a trivial case of input which should not require any fine tuning of ML, but even if I tweak hyperparams for ML (max_depth, eta and so on) nothing changes.

    import pandas as pd
    import xgboost as xgb

    X = pd.DataFrame(([[0], [1], [2], [3], [4], [5]]), columns=['x'])
    y = pd.DataFrame([0, 1, 0, 1, 0, 1], columns=['y'])

    model = xgb.XGBClassifier()
    model.fit(X, y)
    print(model.predict([[0], [1], [2], [3], [4], [5]]))

    [0 0 0 0 0 0]

    Continue reading...

Compartilhe esta Página