Marginal Scores
- unite_toolbox.utils.marginal_scores.power_set(items: collections.abc.Iterable) list[tuple]
Create power set.
Creates a list of tuples which are the power set (all possible combinations) of the input items. Based on the itertools recipe: https://docs.python.org/3/library/itertools.html#itertools-recipes
Parameters
- itemsIterable
Iterable object containing individual labels
Returns
- power_setlist[tuples]
List of tuples containing each element of the power set
- unite_toolbox.utils.marginal_scores.calc_marginal_scores(scores: dict[tuple, float]) dict[Any, float]
Calculate marginal scores due to adding more features.
Calculates the marginal score of adding a specific feature to a callable that generates a score. That callable can be a function (e.g. mutual information) or a model. The result is a marginal gain (or loss) of adding an individual feature as input. The combinations of features are the tuples and each tuple has a specific score associated. The result is a dict of individual features as keys and their marginal score as values.
Parameters
- scoresdict
Dict. of tuples of feature combinations and individual scores i.e. {(): 0.0, (“a”,): 0.3, (“b”,): 0.5, (“c”,): 0.2, (“a”, “b”): 0.8,
(“a”, “c”): 0.5, (“b”, “c”): 0.7, (“a”, “b”, “c”): 1.0}
Returns
- marginal_scoresdict
Dict. of individual labels and their marginal scores i.e. {“a”: 0.3, “b”: 0.5, “c”: 0.2}