Discussion:
[Numpy-discussion] asarray(sparse) -> object
j***@gmail.com
2015-11-20 20:40:16 UTC
Permalink
Is this intentional?
exog
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>
np.asarray(exog)
array(<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>, dtype=object)


I'm just a newbie who thought to use the usual pattern.


....
np.asarray(exog).dot(beta)
array([ <50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>], dtype=object)
C:\programs\WinPython-64bit-3.4.3.1\python-3.4.3.amd64\lib\site-packages\scipy\sparse\compressed.py:306:
SparseEfficiencyWarning: Comparing sparse matrices using >= and <= is
inefficient, using <, >, or !=, instead.
"using <, >, or !=, instead.", SparseEfficiencyWarning)

seems to warn only once
y = np.asarray(exog).dot(beta)
y.shape
(5,)
np.__version__
'1.9.2rc1'
scipy.__version__
'0.15.1'



Josef
CJ Carey
2015-11-20 23:29:08 UTC
Permalink
The short answer is: "kind of".

These two Github issues explain what's going on more in-depth:
https://github.com/scipy/scipy/issues/3995
https://github.com/scipy/scipy/issues/4239

As for the warning only showing once, that's Python's default behavior for
warnings: http://stackoverflow.com/q/22661745/10601

-CJ
Post by j***@gmail.com
Is this intentional?
exog
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>
np.asarray(exog)
array(<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>, dtype=object)
I'm just a newbie who thought to use the usual pattern.
....
np.asarray(exog).dot(beta)
array([ <50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>], dtype=object)
SparseEfficiencyWarning: Comparing sparse matrices using >= and <= is
inefficient, using <, >, or !=, instead.
"using <, >, or !=, instead.", SparseEfficiencyWarning)
seems to warn only once
y = np.asarray(exog).dot(beta)
y.shape
(5,)
np.__version__
'1.9.2rc1'
scipy.__version__
'0.15.1'
Josef
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
j***@gmail.com
2015-11-20 23:57:08 UTC
Permalink
Post by CJ Carey
The short answer is: "kind of".
https://github.com/scipy/scipy/issues/3995
https://github.com/scipy/scipy/issues/4239
Thanks, I didn't pay attention to those issues, or only very superficially.

+1 for doing anything else than converting to object arrays.
Post by CJ Carey
As for the warning only showing once, that's Python's default behavior for
warnings: http://stackoverflow.com/q/22661745/10601
The default should be overwritten for warnings that are always relevant.
I usually don't use sparse arrays, and don't know if this should always
warn.

Josef
Post by CJ Carey
-CJ
Post by j***@gmail.com
Is this intentional?
exog
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>
np.asarray(exog)
array(<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>, dtype=object)
I'm just a newbie who thought to use the usual pattern.
....
np.asarray(exog).dot(beta)
array([ <50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>,
<50x5 sparse matrix of type '<class 'numpy.float64'>'
with 50 stored elements in Compressed Sparse Column format>],
dtype=object)
SparseEfficiencyWarning: Comparing sparse matrices using >= and <= is
inefficient, using <, >, or !=, instead.
"using <, >, or !=, instead.", SparseEfficiencyWarning)
seems to warn only once
y = np.asarray(exog).dot(beta)
y.shape
(5,)
np.__version__
'1.9.2rc1'
scipy.__version__
'0.15.1'
Josef
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...