kb_python icon indicating copy to clipboard operation
kb_python copied to clipboard

Remove np.matrix dependency

Open JohnMMa opened this issue 1 year ago • 1 comments

As most of us may know, numpy is slowly deprecating the np.matrix class. However, the package still has one dependency on this class in report_matrix.ipynb, and scikit-learn is also in the process of doing it (see scikit-learn/scikit-learn#20165). This PR causes the pca.fit_transform's input to switch from np.matrix (the output of csr_matrix.todense()) to np.ndarray (the output of csr_matrix.toarray()`)

However, it must be noted that pca.fit_transform() may have slightly different results depending on its input being np.matrix or np.ndarray, see scikit-learn/scikit-learn#18941. I guess the difference is small enough to matter, but I guess you may think about it a bit.

This is my first PR in the past 5 years, so bear with me.

JohnMMa avatar Jul 25 '23 22:07 JohnMMa

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB