pyccea.fitness package
- class pyccea.fitness.DistanceBasedFitness(evaluator: WrapperEvaluation, weights: list)[source]
Bases:
WrapperFitnessFunction
Objective function that maximizes balanced accuracy based on a k-nearest neighbors classifier.
The fitness function is designed as a three-objective optimization, aimed at achieving a balance between maximizing balanced accuracy while simultaneously minimizing the average distance between instances sharing the same label and maximizing the average distance between instances with different labels.
Firouznia, Marjan, Pietro Ruiu, and Giuseppe A. Trunfio. “Adaptive cooperative coevolutionary differential evolution for parallel feature selection in high-dimensional datasets.” The Journal of Supercomputing (2023): 1-30.
- Attributes:
- w1: float
Predictive performance weight.
- w2: float
Weight of the complement of the average distance between instances and their neighbors with the same class.
- w3: float
Weight of the average distance between instances and their neighbors of different classes.
Methods
evaluate
(context_vector, data)Evaluate the given context vector using the fitness function.
- evaluate(context_vector: ndarray, data: DataLoader)[source]
Evaluate the given context vector using the fitness function.
- Parameters:
- context_vector: np.ndarray
Solution of the complete problem.
- data: DataLoader
Container with process data and training and test sets.
- Returns:
- fitness: float
Quality of the context vector.
- class pyccea.fitness.SubsetSizePenalty(evaluator: WrapperEvaluation, weights: list)[source]
Bases:
WrapperFitnessFunction
Objective function that penalizes large subsets of features.
Rashid, A.N.M Bazlur, et al. “A novel penalty-based wrapper objective function for feature selection in Big Data using cooperative co-evolution.” IEEE Access 8 (2020): 150113-150129.
- Attributes:
- w1: float
Predictive performance weight.
- w2: float
Penalty weight.
Methods
evaluate
(context_vector, data)Evaluate the given context vector using the fitness function.
- evaluate(context_vector: ndarray, data: DataLoader)[source]
Evaluate the given context vector using the fitness function.
- Parameters:
- context_vector: np.ndarray
Solution of the complete problem.
- data: DataLoader
Container with process data and training and test sets.
- Returns:
- fitness: float
Quality of the context vector.
- class pyccea.fitness.WrapperFitnessFunction(evaluator: WrapperEvaluation)[source]
Bases:
ABC
An abstract class for a wrapper objective function.
It measures the quality of a solution according to the predictive performance of a machine learning model.
- Attributes:
- evaluator: object of one of the evaluation classes
Responsible for evaluating individuals, that is, subsets of features.
Submodules
pyccea.fitness.distance module
- class pyccea.fitness.distance.DistanceBasedFitness(evaluator: WrapperEvaluation, weights: list)[source]
Bases:
WrapperFitnessFunction
Objective function that maximizes balanced accuracy based on a k-nearest neighbors classifier.
The fitness function is designed as a three-objective optimization, aimed at achieving a balance between maximizing balanced accuracy while simultaneously minimizing the average distance between instances sharing the same label and maximizing the average distance between instances with different labels.
Firouznia, Marjan, Pietro Ruiu, and Giuseppe A. Trunfio. “Adaptive cooperative coevolutionary differential evolution for parallel feature selection in high-dimensional datasets.” The Journal of Supercomputing (2023): 1-30.
- Attributes:
- w1: float
Predictive performance weight.
- w2: float
Weight of the complement of the average distance between instances and their neighbors with the same class.
- w3: float
Weight of the average distance between instances and their neighbors of different classes.
Methods
evaluate
(context_vector, data)Evaluate the given context vector using the fitness function.
- evaluate(context_vector: ndarray, data: DataLoader)[source]
Evaluate the given context vector using the fitness function.
- Parameters:
- context_vector: np.ndarray
Solution of the complete problem.
- data: DataLoader
Container with process data and training and test sets.
- Returns:
- fitness: float
Quality of the context vector.
pyccea.fitness.function module
- class pyccea.fitness.function.WrapperFitnessFunction(evaluator: WrapperEvaluation)[source]
Bases:
ABC
An abstract class for a wrapper objective function.
It measures the quality of a solution according to the predictive performance of a machine learning model.
- Attributes:
- evaluator: object of one of the evaluation classes
Responsible for evaluating individuals, that is, subsets of features.
pyccea.fitness.penalty module
- class pyccea.fitness.penalty.SubsetSizePenalty(evaluator: WrapperEvaluation, weights: list)[source]
Bases:
WrapperFitnessFunction
Objective function that penalizes large subsets of features.
Rashid, A.N.M Bazlur, et al. “A novel penalty-based wrapper objective function for feature selection in Big Data using cooperative co-evolution.” IEEE Access 8 (2020): 150113-150129.
- Attributes:
- w1: float
Predictive performance weight.
- w2: float
Penalty weight.
Methods
evaluate
(context_vector, data)Evaluate the given context vector using the fitness function.
- evaluate(context_vector: ndarray, data: DataLoader)[source]
Evaluate the given context vector using the fitness function.
- Parameters:
- context_vector: np.ndarray
Solution of the complete problem.
- data: DataLoader
Container with process data and training and test sets.
- Returns:
- fitness: float
Quality of the context vector.