converting scipy.sparse.csr.csr_matrix to a list of lists

后端 未结 3 1031
Happy的楠姐
Happy的楠姐 2021-01-18 13:08

I am learning multi label classification and trying to implement the tfidf tutorial from scikit learning. I am dealing with a text corpus to calculate its tf-idf score. I am

3条回答
  •  没有蜡笔的小新
    2021-01-18 14:06

    For this purpose, proper use of the scipy sparse matrix types is essential scipy.sparse. In this case scipy.sparse.lil_matrix it's ideal, whose "data" attribute stores an np.array of lists that represent the column values. A brief script follows

    arrays_of_list = matriz.tolil().data
    list_of_list = arrays_of_list.tolist()
    

提交回复
热议问题