This project demonstrates how to build, train, and evaluate a multi-class classification model using PyTorch from scratch. It walks through the full machine learning workflow—from data generation to model visualization.
In this project, we generate a synthetic dataset using make_blobs and train a neural network to classify data points into 4 distinct classes based on their features.
The model learns to separate clusters in a 2D space and visualize decision boundaries.
- 📊 Synthetic dataset generation using
sklearn.make_blobs - 🔢 Data preprocessing and conversion to PyTorch tensors
- ✂️ Train-test split for proper evaluation
- 🧠 Custom neural network built with
nn.Module - 🔁 Training and testing loops from scratch
- 📉 Loss calculation using
CrossEntropyLoss - 🎯 Accuracy evaluation
- 📈 Prediction probabilities using
softmax - 🌍 Decision boundary visualization
The model is a simple feedforward neural network with non-linear activation:
Input (2 features)
↓
Linear Layer (2 → 8)
↓
ReLU
↓
Linear Layer (8 → 8)
↓
ReLU
↓
Output Layer (8 → 4 classes)
The goal is to correctly classify each data point into one of the 4 classes based on its position in the feature space.
This project helps you understand:
- Difference between logits, probabilities, and predictions
- Why CrossEntropyLoss is used for multi-class classification
- How softmax + argmax converts model outputs into class labels
- Importance of non-linearity (ReLU) in neural networks
- How to structure a complete PyTorch training pipeline
- The model improves over epochs using gradient descent
- Decision boundary visualization shows how the model learns to separate classes
- Achieves strong classification performance on both training and test data
The project includes:
- Scatter plots of the dataset
- Model decision boundaries for both training and testing data
- PyTorch
- Scikit-learn
- Matplotlib
This is a core deep learning project that builds a strong foundation for:
- Multi-class classification problems
- Neural network design
- Model evaluation and debugging
- Transitioning to real-world datasets
- Experiment with deeper networks
- Try different optimizers (Adam, RMSprop)
- Apply the model to real datasets
- Improve accuracy with hyperparameter tuning
💡 This project is a great stepping stone toward mastering deep learning and building real-world AI systems.