pyrfume.optimization module¶
-
class
pyrfume.optimization.
OdorantSetOptimizer
(library: pandas.core.frame.DataFrame, n_desired: int, weights: list, keep_cids: bool = None, fitness=None, n_gen: int = 300, mu: int = 100, lamda: int = 200, p_cx: float = 0.4, p_mut: float = 0.4, sel='selBest', standardize_weights=False, npartitions=1)[source]¶ Bases:
object
-
compute_weight_stats
()[source]¶ Compute scores for a bunch of random individuals to use for standardizing fitness scores and thus making weights interpretable as # of sd’s better or worse than random individuals
-
crossover
(ind1, ind2) → tuple[source]¶ Apply a crossover operation on input sets.
- Args:
- ind1: The first individual ind2: The second individual
- Returns:
- tuple: Two new individuals
-
dask_map
(f, x: list) → list[source]¶ A mapping function for Dask. Used for multithreading.
- Args:
f: Any function. x (list): A list of inputs to be sequentially passed
to that function.- Returns:
- list: A list of outputs from that function.
-
eval_individual
(individual, standardize: bool = None)[source]¶ Evaluate the fitness of the odorant set.
- Args:
individual: A DEAP individual as registered above. standardize (bool, optional): Whether to standardize the
resulting score.- Returns:
- A fitness score.
-
eval_mean
(individual, column: str) → float[source]¶ Evaluation the mean of column for the selected individual
- Args:
- individual: An individual. column (str): A column name from the library dataframe.
- Returns:
- float: The mean of that column, for the subset
- described by the individual
-
eval_sum
(individual, column: str)[source]¶ Evaluation the sum of column for the selected individual
- Args:
- individual: An individual. column (str): A column name from the library dataframe.
- Returns:
- float: The sum of that column, for the subset
- described by the individual
-
force_keep
(ind)[source]¶ Ensure that the CIDs in self.keep get included
- Args:
- ind: An individual.
- Returns:
- An individual with certain additional items kept.
-
-
pyrfume.optimization.
get_coverage
(odorant_indices, space, sigma=2)[source]¶ This function will be used to compute coverage of odorant space during optimization. We want non-selected odorants to be ‘covered’ as much as possible by selected ones