pica.util package

Submodules

pica.util.helpers module

pica.util.helpers.get_groups(records: List[pica.structure.records.TrainingRecord]) → numpy.ndarray[source]

Get groups from list of TrainingRecords

Parameters

records

Returns

list for groups

pica.util.helpers.get_x_y_tn(records: List[pica.structure.records.TrainingRecord]) → Tuple[numpy.ndarray, numpy.ndarray, str][source]

Get separate X and y from list of TrainingRecord. Also infer trait name from first TrainingRecord.

Parameters

records – a List[TrainingRecord]

Returns

separate lists of features and targets, and the trait name

pica.util.logging module

pica.util.logging.get_logger(initname, verb=False)[source]

This function provides a logger to all scripts used in this project.

Parameters
  • initname – The name of the logger to show up in log.

  • verb – Toggle verbosity

Returns

the finished Logger object.

pica.util.plotting module

pica.util.plotting.compleconta_plot(cccv_results: List[Dict[float, Dict[float, Dict[str, float]]]], conditions: List[str] = (), each_n: List[int] = None, title: str = '', fontsize: int = 16, figsize=(10, 7), plot_comple: bool = True, plot_conta: bool = True, colors: List = None, save_path: Union[str, pathlib.Path] = None, **kwargs)[source]

Plots Compleconta CV result for one or multiple models. For perfect completeness and variable contamination as well as perfect contamination and variable completeness, the resulting mean balanced accuracy over folds is plotted.

Parameters
  • cccv_results – a ComplecontaCV result, or list thereof

  • conditions – A list of condition names associated cccv_results

  • each_n – A list of sample counts in datasets associated with cccv_results

  • title – The plot title

  • fontsize – The fontsize of the plot

  • figsize – The figure size (tuple of width, height)

  • plot_comple – Whether to plot completeness

  • plot_conta – Whether to plot contamination

  • colors

  • save_path – The save path of the plot; if None, display it with plt.show()

  • kwargs – any further keyword arguments passed to plt.plot()

Returns

None

pica.util.serialization module

pica.util.serialization.load_classifier(filename: str, verb=False)[source]

Load a pickled TrexClassifier to a usable object.

Parameters
  • filename – Input filename

  • verb – Toggle verbosity

Returns

a unpickled PICA ml classifier

pica.util.serialization.save_classifier(obj, filename: str, overwrite=False, verb=False)[source]

Save a TrexClassifier as a pickled object.

Parameters
  • obj – the Python3 object to be saved.

  • filename – Output filename

  • overwrite – Overwrite existing files with same name

  • verb – Toggle verbosity

pica.util.taxonomy module

Module contents