Skip to content

YerimahOfTimes/Neural-Network-Classification-With-Pytorch-Multi-class-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

🔥 PyTorch Multi-Class Classification (Blobs Dataset)

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.


📌 Project Overview

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.


⚙️ Key Features

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

🧠 Model Architecture

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)

🎯 Objective

The goal is to correctly classify each data point into one of the 4 classes based on its position in the feature space.


🚀 Learning Highlights

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

📊 Results

  • 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

🖼️ Visualization

The project includes:

  • Scatter plots of the dataset
  • Model decision boundaries for both training and testing data

🧰 Tools & Libraries

  • PyTorch
  • Scikit-learn
  • Matplotlib

💡 Why This Project Matters

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

🔥 Next Steps

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

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors