Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
e36cc9c1
Unverified
Commit
e36cc9c1
authored
Jul 06, 2021
by
James Lamb
Committed by
GitHub
Jul 07, 2021
Browse files
[python-package] use toarray() instead of todense() in tests and examples (#4446)
parent
ec1debce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
examples/python-guide/dask/ranking.py
examples/python-guide/dask/ranking.py
+1
-1
tests/python_package_test/test_engine.py
tests/python_package_test/test_engine.py
+2
-2
No files found.
examples/python-guide/dask/ranking.py
View file @
e36cc9c1
...
...
@@ -30,7 +30,7 @@ if __name__ == "__main__":
# make this array dense because we're splitting across
# a sparse boundary to partition the data
X
=
X
.
to
dense
()
X
=
X
.
to
array
()
dX
=
da
.
from_array
(
x
=
X
,
...
...
tests/python_package_test/test_engine.py
View file @
e36cc9c1
...
...
@@ -1087,7 +1087,7 @@ def test_contribs_sparse_multiclass():
# convert data to dense and get back same contribs
contribs_dense
=
gbm
.
predict
(
X_test
.
toarray
(),
pred_contrib
=
True
)
# validate the values are the same
contribs_csr_array
=
np
.
swapaxes
(
np
.
array
([
sparse_array
.
to
dense
()
for
sparse_array
in
contribs_csr
]),
0
,
1
)
contribs_csr_array
=
np
.
swapaxes
(
np
.
array
([
sparse_array
.
to
array
()
for
sparse_array
in
contribs_csr
]),
0
,
1
)
contribs_csr_arr_re
=
contribs_csr_array
.
reshape
((
contribs_csr_array
.
shape
[
0
],
contribs_csr_array
.
shape
[
1
]
*
contribs_csr_array
.
shape
[
2
]))
if
platform
.
machine
()
==
'aarch64'
:
...
...
@@ -1103,7 +1103,7 @@ def test_contribs_sparse_multiclass():
for
perclass_contribs_csc
in
contribs_csc
:
assert
isspmatrix_csc
(
perclass_contribs_csc
)
# validate the values are the same
contribs_csc_array
=
np
.
swapaxes
(
np
.
array
([
sparse_array
.
to
dense
()
for
sparse_array
in
contribs_csc
]),
0
,
1
)
contribs_csc_array
=
np
.
swapaxes
(
np
.
array
([
sparse_array
.
to
array
()
for
sparse_array
in
contribs_csc
]),
0
,
1
)
contribs_csc_array
=
contribs_csc_array
.
reshape
((
contribs_csc_array
.
shape
[
0
],
contribs_csc_array
.
shape
[
1
]
*
contribs_csc_array
.
shape
[
2
]))
if
platform
.
machine
()
==
'aarch64'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment