Skip to content

Gokultcr/Automatic_feature_selection-on-SVM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Automatic Feature Selection using Ant Colony Optimization (ACO)

This script demonstrates the application of Ant Colony Optimization (ACO) for feature selection in a machine learning pipeline.

Problem Description:

  • 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.

    Note that for better accuracy you need to replace the parameters.

  1. 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.
  2. 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.
  3. 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.

Code Explanation:

Data Preprocessing:

  • 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.

Feature Selection with ACO:

  • 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, and q0 are set to control the behavior of the algorithm.

Model Training and Evaluation:

  • 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.

Results:

  • 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.

Further Improvements:

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published