BasicGA Class

Basic single objective genetic algorithm

class spiegelib.estimator.BasicGA(synth, features, seed=None, pop_size=100, ngen=25, cxpb=0.5, mutpb=0.3)

Bases: spiegelib.estimator.estimator_base.EstimatorBase

Parameters
  • synth (Object) – Instance of spiegelib.synth.SynthBase

  • features (Object) – Instance of spiegelib.features.FeaturesBase. This is used in the evaluation function to determine fitness of an individual.

  • seed (int, optional) – Seed for random. Defaults to current system time.

  • pop_size (int, optional) – Size of population at each generation

  • ngen (int, optional) – Number of generations to run

  • cxpb (float, optional) – Crossover probability, must be between 0 and 1.

  • mutpb (float, optional) – Mutation probability, must be between 0 and 1.

fitness(individual)

This is automatically called during prediction. Evaluation that calculates the fitness of an individual. The individual is a new estimated synthesizer parameter setting, and fitness is calculated by rendering an audio sample using those parameter settings and then measuring the error between that sample and the target sound using audio feature extraction. The type of feature extraction is set in the constructor.

Parameters

individual (list) – List of float values representing a synthesizer patch

Returns

A list of the error values (b/c this is a single objective GA the list only has one element)

Return type

list

predict(input)

Run GA prection on input audio target

Parameters

input (AudioBuffer) – AudioBuffer to use as target