A Python tool for visualizing linear separability concepts using machine learning classifiers on the Wine dataset.
This repository demonstrates the concept of linear separability in machine learning by applying different classification algorithms to the Wine dataset. It visualizes data distributions, decision boundaries, and classification performance metrics to help understand how different algorithms separate data points in feature space.
- π Data visualization using scatter plots and scatter matrices
- π· Convex hull visualization to show class boundaries
- π Implementation of multiple classifiers:
- Perceptron (linear classifier)
- Support Vector Machine with linear kernel
- Support Vector Machine with RBF kernel (non-linear)
- π Decision boundary visualization for each classifier
- π Confusion matrix generation to evaluate classifier performance
- Python 3.6+
- Required libraries:
pandas numpy scikit-learn matplotlib scipy
-
Clone the repository:
git clone https://github.com/corticalstack/LinearSeparability.git cd LinearSeparability
-
Install the required dependencies:
pip install pandas numpy scikit-learn matplotlib scipy
-
Run the main script:
python main.py
-
Observe the generated visualizations:
- Scatter matrix of the first 4 features
- Scatter plot of alcohol vs malic acid features with class coloring
- Convex hull visualization of class boundaries
- Decision boundaries and confusion matrices for each classifier
The LinearSeparability
class performs the following steps:
- Loads the Wine dataset from scikit-learn
- Creates visualizations of the dataset features
- Implements three different classifiers:
- Perceptron: A simple linear classifier
- SVM with linear kernel: A more robust linear classifier
- SVM with RBF kernel: A non-linear classifier
- For each classifier, it:
- Trains on the first two features (alcohol and malic acid)
- Visualizes the decision boundary
- Displays a confusion matrix to evaluate performance
- The project focuses on binary classification by converting the Wine dataset (which has 3 classes) into a binary problem (class 1 vs. others)
- The visualization shows how different algorithms create decision boundaries between classes
- Demonstrates the difference between linear classifiers (Perceptron, linear SVM) and non-linear classifiers (RBF SVM)
This project is licensed under the MIT License - see the LICENSE file for details.