зеркало из https://github.com/microsoft/LightGBM.git
[python-package] use toarray() instead of todense() in tests and examples (#4446)
This commit is contained in:
Родитель
ec1debcee8
Коммит
e36cc9c171
|
@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
# make this array dense because we're splitting across
|
# make this array dense because we're splitting across
|
||||||
# a sparse boundary to partition the data
|
# a sparse boundary to partition the data
|
||||||
X = X.todense()
|
X = X.toarray()
|
||||||
|
|
||||||
dX = da.from_array(
|
dX = da.from_array(
|
||||||
x=X,
|
x=X,
|
||||||
|
|
|
@ -1087,7 +1087,7 @@ def test_contribs_sparse_multiclass():
|
||||||
# convert data to dense and get back same contribs
|
# convert data to dense and get back same contribs
|
||||||
contribs_dense = gbm.predict(X_test.toarray(), pred_contrib=True)
|
contribs_dense = gbm.predict(X_test.toarray(), pred_contrib=True)
|
||||||
# validate the values are the same
|
# validate the values are the same
|
||||||
contribs_csr_array = np.swapaxes(np.array([sparse_array.todense() for sparse_array in contribs_csr]), 0, 1)
|
contribs_csr_array = np.swapaxes(np.array([sparse_array.toarray() for sparse_array in contribs_csr]), 0, 1)
|
||||||
contribs_csr_arr_re = contribs_csr_array.reshape((contribs_csr_array.shape[0],
|
contribs_csr_arr_re = contribs_csr_array.reshape((contribs_csr_array.shape[0],
|
||||||
contribs_csr_array.shape[1] * contribs_csr_array.shape[2]))
|
contribs_csr_array.shape[1] * contribs_csr_array.shape[2]))
|
||||||
if platform.machine() == 'aarch64':
|
if platform.machine() == 'aarch64':
|
||||||
|
@ -1103,7 +1103,7 @@ def test_contribs_sparse_multiclass():
|
||||||
for perclass_contribs_csc in contribs_csc:
|
for perclass_contribs_csc in contribs_csc:
|
||||||
assert isspmatrix_csc(perclass_contribs_csc)
|
assert isspmatrix_csc(perclass_contribs_csc)
|
||||||
# validate the values are the same
|
# validate the values are the same
|
||||||
contribs_csc_array = np.swapaxes(np.array([sparse_array.todense() for sparse_array in contribs_csc]), 0, 1)
|
contribs_csc_array = np.swapaxes(np.array([sparse_array.toarray() for sparse_array in contribs_csc]), 0, 1)
|
||||||
contribs_csc_array = contribs_csc_array.reshape((contribs_csc_array.shape[0],
|
contribs_csc_array = contribs_csc_array.reshape((contribs_csc_array.shape[0],
|
||||||
contribs_csc_array.shape[1] * contribs_csc_array.shape[2]))
|
contribs_csc_array.shape[1] * contribs_csc_array.shape[2]))
|
||||||
if platform.machine() == 'aarch64':
|
if platform.machine() == 'aarch64':
|
||||||
|
|
Загрузка…
Ссылка в новой задаче