wrapper module

wrapper.evaluate_knn_python(individual, knn: knn.Knn)[source]

Evaluation of an individual by using the Scikit-learn k-NN

Parameters:
  • individual – Individual (potential solution)
  • knn (Knn) – knn object
  • p – Probability of applying mutation

:return Individual evaluted (fitness assignment)

wrapper.evaluation(population, knn: knn.Knn, config: config.Config)[source]

Function to choose between the different k-NN implementations

Parameters:
  • population – Entire population
  • knn (Knn) – knn object
  • config – Config object where all the hyperparameter values are loaded
wrapper.feature_selection(knn: knn.Knn, config: config.Config)[source]

Main function to perform the feature selection

Parameters:
  • knn (Knn) – knn object
  • config – Config object where all the hyperparameter values are loaded

:return data_backup : Backup of the wrapper execution data :rtype: dict

wrapper.fill_chromosome(p: float, features: int)[source]

Fill the chromosome with random features

Parameters:
  • p – Probability of each feature being selected
  • features – Number of features of the dataset

:return Array with selected features :rtype: numpy.array

wrapper.genetic_algorithm(population, knn: knn.Knn, config: config.Config, sub_pop: int, q_in, q_out, q, data_queue)[source]

Implementation of the NSGA-II steps

Parameters:
  • population – Entire population
  • knn (Knn) – knn object
  • config – Config object where all the hyperparameter values are loaded
  • sub_pop – subpopulation index
  • q_in – queue to put migrants to be send on to next subpopulation
  • q_put – queue to receive migrants
  • q – queue to send the entire population at the end of the wrapper execution
  • data_Qqeue – queue to send relevant information about wrapper execution
wrapper.migration(population, subpops: int, sub_population_size: int)[source]

Migration between different subpopulations: every subpopulation gives the half of its Pareto front to the next subpopulation following a ring topology.

Parameters:
  • population – Entire population
  • subpops – Number of subpopulations
  • sub_population_size – Number of individuals of each subpopulation
wrapper.mutate(individual, features: int, pm: float)[source]

Mutate to an individual with integer representation

Parameters:
  • individual – Individual (potential solution)
  • features – Number of features of the dataset
  • p – Probability of applying mutation

:return Individual mutated

wrapper.random_feature(features: int)[source]

Generation of an array with a one randome feature

Parameters:features – Number of features of the dataset

:return Array with one selected feature :rtype: numpy.array

wrapper.recombination_and_mutation(pool, config: config.Config)[source]

Recombination of the pool’s individuals

Parameters:
  • pool – Pool of individuals
  • config – Config object where all the hyperparameter values are loaded

:return Offspring