This script demonstrates the application of Ant Colony Optimization (ACO) for feature selection in a machine learning pipeline.
-
The script addresses a classification problem aimed at distinguishing between normal and defective wood samples.
-
The dataset contains images of both normal and defective wood samples.
-
The task involves extracting features from the images and training a classification model to differentiate between the two classes.
-
Data Preprocessing:
- Images of different tree species are loaded and features are extracted using GLCM (Gray Level Co-occurrence Matrix).
- The data is split into training, validation, and testing sets.
-
Feature Selection with ACO:
- ACO algorithm is applied to select an optimal subset of features.
- The algorithm iteratively selects features based on pheromone levels and heuristic information.
- Parameters like the number of ants, alpha, beta, and evaporation rate are set to guide the search.
-
Model Training and Evaluation:
- Support Vector Machine (SVM) classifier is trained using the selected features.
- Performance is evaluated on the training, validation, and testing sets.
- Accuracy and classification reports are generated for each set.
- The script loads images of different tree species and extracts features using GLCM.
- Images are resized to a standard size (
SIZE = 200
) before feature extraction. - Features extracted include Energy, Dissimilarity, Homogeneity, and Contrast.
- ACO class is defined to perform feature selection.
- The ACO algorithm iteratively selects features based on pheromone levels and heuristic information.
- Parameters like
num_ants
,alpha
,beta
,evaporation_rate
, andq0
are set to control the behavior of the algorithm.
- Support Vector Machine (SVM) classifier is trained using the selected features.
- Performance is evaluated using accuracy metrics and classification reports.
- Separate evaluations are done for training, validation, and testing sets.
- The script provides insights into the performance of the ACO-based feature selection method.
- It allows comparison of accuracy and classification reports for different sets.
- The feature importance is visualized through a bar plot of SVM coefficients.
- Hyperparameters of ACO and SVM can be fine-tuned for better performance.
- Other feature selection techniques like Genetic Algorithms or Recursive Feature Elimination can be explored.