SciPy

tethne.persistence.hdf5.dtmmodel module

class tethne.persistence.hdf5.dtmmodel.HDF5DTMModel(e_theta=None, phi=None, metadata=None, vocabulary=None, datapath=None)[source]

Bases: tethne.model.corpus.dtmmodel.DTMModel

Provides HDF5 persistence for DTMModel.

If datapath is provided, and points to a real HDF5 file, then no other parameters need be provided.

Parameters:

e_theta : matrix-like

Distribution of topics (Z) in documents (M). Shape: (Z, M).

phi : matrix-like

Topic (Z) distribution over words (W), over time (T). Shape: (Z, W, T)

metadata : dict

Maps matrix indices onto document datadata.

vocabulary : dict

Maps W indices onto words.

datapath : str

(optional) Path to an HDF5 repository. If not provided, generates a temporary path, which can be accessed as the .path attribute.

tethne.persistence.hdf5.dtmmodel.from_hdf5(HD_or_path)[source]

Load a DTMModel from a HDF5DTMModel.

Parameters:

HD_or_path : str or HDF5DTMModel

If str, must be a path to a HDF5DTMModel HDF5 repo.

Returns:

model : DTMModel

Examples

From a path:

>>> model = from_hdf5('/path/to/my/HDF5DTMModel.h5')
tethne.persistence.hdf5.dtmmodel.to_hdf5(model, datapath=None)[source]

Generate a HDF5DTMModel from the current instance.

Parameters:

model : DTMModel

datapath : str

(optional) Path to an HDF5 repository. If not provided, generates a temporary path, which can be accessed as the .path attribute.

Returns:

hdf5_model : HDF5DTMModel