ich Python bin mit scikit-learn
für Dokumenten-Clustering und ich habe eine Sparse Matrix in einem dict
Objekt gespeichert:Python Sparse Matrix dict Konvertieren Sparse Matrix SciPy
Zum Beispiel:
doc_term_dict = { ('d1','t1'): 12, \
('d2','t3'): 10, \
('d3','t2'): 5 \
} # from mysql data table
<type 'dict'>
Ich mag zu verwenden scikit-learn
, um das Clustering zu tun, wo der Eingabe-Matrix-Typ ist scipy.sparse.csr.csr_matrix
Beispiel:
(0, 2164) 0.245793088885
(0, 2076) 0.205702177467
(0, 2037) 0.193810934784
(0, 2005) 0.14547028437
(0, 1953) 0.153720023365
...
<class 'scipy.sparse.csr.csr_matrix'>
Ich kann nicht einen Weg finden, dict
diese csr-Matrix zu konvertieren (ich nie scipy
verwendet habe.)
danke @dataman meine Frage bearbeitet – chent