pydruglogics.model.Evolution module
- class pydruglogics.model.Evolution.Evolution(boolean_model=None, training_data=None, model_outputs=None, ga_args=None, ev_args=None)
Bases:
BooleanModelOptimizer
Initializes the Evolution class with a BooleanModel and genetic algorithm parameters. :param boolean_model: The boolean model to be evolved. :param training_data: Training data for the model. :param model_outputs: Model outputs for evaluation. :param ga_args: Dictionary containing all necessary arguments for pygad. :param ev_args: Dictionary containing all necessary arguments for running the evolution.
- property best_boolean_models: List[BooleanModel]
- calculate_fitness(ga_instance, solutions, solution_idx)
Calculates fitness for a batch of solutions. Each solution is evaluated in a batch, and a fitness score is returned for each. :param ga_instance: Instance of the GA. It is required by PayGAD. :param solutions: A batch of solutions (list of binary vectors). It is required by PayGAD. :param solution_idx: The index of the current solution batch. It is required by PayGAD. :return: A list of fitness values, one for each solution in the batch.
- create_initial_population(population_size, num_mutations, seed=None)
Creates an initial population for the GA. :param population_size: The number of individuals in the population. :param num_mutations: The number of mutations to perform on each individual. :param seed: Seed for reproducibility. :return: List of binary vectors representing the initial population.
- run()
- save_to_file_models(base_folder='./results/models')