PyTablesでnumpyのcsr_matrixを保存するのに問題があります。私はこのエラーを取得しています:HDF5(PyTables)にnumpyの疎な行列を保存する
TypeError: objects of type ``csr_matrix`` are not supported in this context, sorry; supported objects are: NumPy array, record or scalar; homogeneous list or tuple, integer, float, complex or string
マイコード:
f = tables.openFile(path,'w')
atom = tables.Atom.from_dtype(self.count_vector.dtype)
ds = f.createCArray(f.root, 'count', atom, self.count_vector.shape)
ds[:] = self.count_vector
f.close()
任意のアイデア?
おかげ
ディスク上のデータのサイズが心配ですか?私はhdf5ファイルを圧縮形式で保存することができます。その場合、密度の高い行列を保存するだけで済むかもしれません。 – user545424
http://stackoverflow.com/questions/8895120/using-pytables-which-is-more-efficient-scipy-sparse-or-numpy-dense-matrixを参照してください。スパース行列のpytablesサポートがないようです。 – user545424