magmap.stats.mlearn module#

Machine learning and output for MagellanMapper.

class magmap.stats.mlearn.GridSearchStats(value)[source]#

Bases: Enum

Grid search statistics categories.

FDR = 'FDR'#
FN = 'FN'#
FP = 'FP'#
PARAM = 'Par'#
POS = 'Pos'#
PPV = 'PPV'#
SENS = 'Sens'#
TN = 'TN'#
TP = 'TP'#

Perform a grid search for hyperparameter optimization.

A separate grid search will be performed for each item in roc_dict. Note that currently each subsequent grid search will use the last settings from the prior search.

Parameters:
  • hyperparams (OrderedDict[str, Sequence[float]]) – Ordered dictionary with sequences of the format: (:class:`profiles.ROIProfile` parameter, (a, b, c, ...)).

  • fnc (Callable[[Any], Tuple[Any, Sequence]]) – Function to call during the grid search, which must return stats, summaries.

  • *fnc_args – Arguments to pass to fnc.

Return type:

OrderedDict[str, Tuple[Sequence, Sequence, str, OrderedDict]]

Returns:

Dictionary of stats suitable for parsing in parse_grid_stats().

magmap.stats.mlearn.parse_grid_stats(stats)[source]#

Parse stats from a grid search.

Parameters:

stats (OrderedDict[str, Tuple[Sequence, Sequence, str, OrderedDict]]) – Dictionary where key is a string with the parameters up to the last parameter group, and each value is a tuple of the raw stats as (pos, true_pos, false_pos); the array of values for the last parameter; the last parameter key; and an OrderedDict of the parent parameters and their values for the given set of stats.

Returns:

  • group_stats is a dictionary of stats, where keys correspond go stats keys, and values are tuples of the false discovery rate, sensitivity, and last parameter group value, each as sequences

  • df is a data frame summarizing the stats

Return type:

Tuple of group_stats and df