Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/python_package_test/test_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -2013,6 +2013,31 @@ def test_contribs_sparse_multiclass():
np.testing.assert_allclose(contribs_csc_array, contribs_dense)


def test_predict_contrib_int64():
n_samples = 100
n_features = 5

X, y = make_multilabel_classification(
n_samples=n_samples, sparse=True, n_features=n_features, n_classes=1, n_labels=2
)
y = y.flatten()
X_train, X_test, y_train, _ = train_test_split(X, y, test_size=0.1, random_state=42)
X_test.indptr = X_test.indptr.astype(np.int64)

train_data = lgb.Dataset(X_train, label=y_train)
params = {"objective": "binary", "num_leaves": 7, "learning_rate": 0.1, "verbose": -1}
booster = lgb.Booster(params, train_data)

for _ in range(5):
booster.update()

preds = booster.predict(X_test, pred_contrib=True, num_iteration=booster.best_iteration)

assert preds is not None
assert preds.shape[0] == X_test.shape[0]
assert preds.shape[1] == X_test.shape[1] + 1


# @pytest.mark.skipif(psutil.virtual_memory().available / 1024 / 1024 / 1024 < 3, reason="not enough RAM")
# def test_int32_max_sparse_contribs(rng):
# params = {"objective": "binary"}
Expand Down
Loading