Last answered:

07 Aug 2023

Posted on:

05 Aug 2023

0

what should i use for fitting x_train_transf or x_train_transf.toarray()

what should i use for fitting x_train_transf or x_train_transf.toarray().

are both the things same or not?

1 answers ( 0 marked as helpful)
Instructor
Posted on:

07 Aug 2023

1

Hey Ram,


Thank you for reaching out!


The variable x_train_transf is a scipy csr_matrix object that we cannot easily inspect. You can read more about it in scipy's official documentation:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html


Scrolling down the page, you can notice that csr_matrix objects have a method called toarray(). What this method does is converting a csr_matrix object to a more easily readable numpy N-dimensional array object (an ndarray).


The only reason we use the toarray() method in the lectures is to display the matrix and study its content.


Hope this helped! Let me know if you have other questions.


Kind regards,

365 Hristina

Submit an answer