Support column major array. (#6765)

This commit is contained in:
Jiaming Yuan
2021-03-20 05:19:46 +08:00
committed by GitHub
parent f6fe15d11f
commit 4ee8340e79
9 changed files with 181 additions and 151 deletions

View File

@@ -2,7 +2,10 @@
from concurrent.futures import ThreadPoolExecutor
import numpy as np
from scipy import sparse
import pytest
import pandas as pd
import testing as tm
import xgboost as xgb
@@ -147,6 +150,19 @@ class TestInplacePredict:
for i in range(10):
run_threaded_predict(X, self.rows, predict_csr)
@pytest.mark.skipif(**tm.no_pandas())
def test_predict_pd(self):
X = self.X
# construct it in column major style
df = pd.DataFrame({str(i): X[:, i] for i in range(X.shape[1])})
booster = self.booster
df_predt = booster.inplace_predict(df)
arr_predt = booster.inplace_predict(X)
dmat_predt = booster.predict(xgb.DMatrix(X))
np.testing.assert_allclose(dmat_predt, arr_predt)
np.testing.assert_allclose(df_predt, arr_predt)
def test_base_margin(self):
booster = self.booster