Load saved models

pyPLNmodels.load_model(path_of_directory: str) Dict[str, Any]

Load Pln or PlnPCA model (that has previously been saved) from the given directory for future initialization.

Parameters:

path_of_directory (str) – The path to the directory containing the model.

Returns:

A dictionary containing the loaded model.

Return type:

Dict[str, Any]

Examples

>>> from pyPLNmodels import PlnPCA, Pln, get_real_count_data, load_model
>>> endog= get_real_count_data()
>>> pca = PlnPCA(endog, add_const = True)
>>> pca.fit()
>>> pca.save()
>>> dict_init = load_model("PlnPCA_nbcov_1_dim_200_rank_5")
>>> loaded_pca = PlnPCA(endog, add_const = True, dict_initialization = dict_init)
>>> print(loaded_pca)
>>> pln = Pln(endog, add_const = True)
>>> pln.fit()
>>> pln.save()
>>> dict_init = load_model("Pln_nbcov_1_dim_200")
>>> loaded_pln = Pln(endog, add_const = True, dict_initialization = dict_init)
>>> print(loaded_pln)
pyPLNmodels.load_plnpcacollection(path_of_directory: str, ranks: List[int] | None = None) Dict[int, Dict[str, Any]]

Load PlnPCAcollection models from the given directory.

Parameters:
  • path_of_directory (str) – The path to the directory containing the PlnPCAcollection models.

  • ranks (List[int], optional) – A List of ranks specifying which models to load. If None, all models in the directory will be loaded.

Returns:

A dictionary containing the loaded PlnPCAcollection models, with ranks as keys.

Return type:

Dict[int, Dict[str, Any]]

Raises:

ValueError – If an invalid model name is encountered and the rank cannot be determined.

Examples

>>> from pyPLNmodels import PlnPCAcollection, get_real_count_data, load_plnpcacollection
>>> endog = get_real_count_data()
>>> pcas = PlnPCAcollection(endog, add_const = True, ranks = [4,5,6])
>>> pcas.fit()
>>> pcas.save()
>>> dict_init = load_plnpcacollection("PlnPCAcollection_nbcov_1_dim_200")
>>> loaded_pcas = PlnPCAcollection(endog, add_const = True, ranks = [4,5,6], dict_of_dict_initialization = dict_init)
>>> print(loaded_pcas)

See also

load_model()

pyPLNmodels.load_pln(path_of_directory: str) Dict[str, Any]

Alias for load_model().

pyPLNmodels.load_plnpca(path_of_directory: str) Dict[str, Any]

Alias for load_model().