Sto usando python scikit-learn
per il documento clustering e ho una matrice sparsa memorizzato in un oggetto dict
:Conversione pitone sparse dict matrice per SciPy matrici sparse
Ad esempio:
doc_term_dict = { ('d1','t1'): 12, \
('d2','t3'): 10, \
('d3','t2'): 5 \
} # from mysql data table
<type 'dict'>
voglio utilizzare scikit-learn
per eseguire il clustering in cui il tipo di matrice di input è scipy.sparse.csr.csr_matrix
Esempio:
(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'>
non riesco a trovare un modo per convertire dict
a questo CSR-matrice (non ho mai usato scipy
.)
grazie @dataman ha modificato la mia domanda – chent