A comprehensive collection of pattern recognition and machine learning implementations developed for university coursework. This repository contains practical implementations of fundamental algorithms and techniques in pattern recognition, computer vision, and deep learning.
This repository provides a hands-on introduction to modern pattern recognition, covering the journey from basic classifiers to advanced deep learning techniques. The projects progress through:
- Fundamental Classifiers: Implementation of perceptron and k-NN classifiers for digit recognition
- Evaluation Metrics: Development of comprehensive evaluation frameworks
- Statistical Learning: Logistic regression and probabilistic approaches
- Feature Engineering: Image processing and feature extraction techniques
- Deep Learning: Autoencoders and neural network approaches
- Advanced Applications: Medical image segmentation and latent space modeling
The course emphasizes building a probabilistic framework for pattern recognition, deriving optimal classifiers, and exploring both traditional feature design and modern deep learning approaches.
Pattern-Recognition/
├── 1/ # Assignment 1: Basic Classifiers
│ ├── perceptron.py # Multi-class perceptron implementation
│ ├── knn.py # k-Nearest Neighbors classifier
│ ├── document_classification.py # Text classification using k-NN
│ ├── random_classifier.py # Random baseline classifier
│ └── PR23_assignment1.pdf # Assignment instructions
├── 2/ # Assignment 2: Evaluation Metrics
│ ├── metrics.py # Comprehensive evaluation metrics
│ └── PR23_assignment2.pdf # Assignment instructions
├── 3/ # Assignment 3: Logistic Regression
│ ├── logistic.py # Logistic regression implementation
│ ├── classifier.py # Advanced classification techniques
│ ├── filter.py # Image filtering operations
│ └── PR23_assignment3.pdf # Assignment instructions
├── 4/ # Assignment 4: Feature Engineering
│ ├── data_loader.py # BSDS300 dataset loader
│ ├── feature.py # Feature extraction methods
│ ├── gradient_feature.py # Gradient-based features
│ ├── boundary.py # Boundary detection algorithms
│ ├── filter.py # Advanced filtering techniques
│ ├── logistic.py # Logistic regression for features
│ ├── metrics.py # Performance evaluation
│ └── PR23_assignment4.pdf # Assignment instructions
├── 5/ # Assignment 5: Image Restoration
│ ├── *.pt # Pre-trained PyTorch models
│ ├── *.png # Result visualizations
│ └── Pattern_Recognition_Exercises_2023-5.pdf
├── 6/ # Assignment 6: Deep Learning
│ ├── latent.ipynb # Autoencoder and latent space analysis
│ ├── segment.ipynb # Medical image segmentation
│ └── PR23_assignment6.pdf # Assignment instructions
├── Test/ # Sample implementations
│ └── sample.py # Basic mathematical operations
├── LICENSE # MIT License
└── README.md # This file
- Multi-class Perceptron: Implementation for MNIST digit recognition
- k-Nearest Neighbors: Distance-based classification algorithm
- Document Classification: Text classification using bag-of-words and k-NN
- Random Classifier: Baseline comparison model
Key Concepts: Basic classification, one-hot encoding, distance metrics, text preprocessing
- Classification Metrics: Accuracy, precision, recall, F1-score
- ROC Analysis: ROC curves and AUC computation
- Statistical Evaluation: Comprehensive performance assessment
Key Concepts: Model evaluation, statistical measures, performance comparison
- Logistic Regression: Sigmoid function, gradient descent optimization
- Advanced Classification: Feature standardization, ROC analysis
- Image Filtering: Convolution operations, frequency domain processing
Key Concepts: Probabilistic classification, optimization, signal processing
- Dataset Handling: BSDS300 image dataset loader
- Feature Extraction: Texture, color, and brightness gradient features
- Boundary Detection: Edge detection and segmentation
- Gradient Features: Multi-scale and orientation-based features
Key Concepts: Computer vision, feature engineering, image processing
- Deep Learning Models: Pre-trained networks for image restoration
- Applications: Denoising, deblurring, and enhancement
- Evaluation: Visual and quantitative assessment
Key Concepts: Image restoration, deep learning applications, model evaluation
- Autoencoders: Dimensionality reduction and latent space modeling
- Medical Image Segmentation: U-Net architecture for polyp segmentation
- Generative Modeling: Sampling from latent space representations
Key Concepts: Deep learning, autoencoders, medical imaging, segmentation
numpy>=1.21.0
matplotlib>=3.5.0
scipy>=1.7.0
scikit-learn>=1.0.0
pandas>=1.3.0torch>=1.10.0
torchvision>=0.11.0
segmentation-models-pytorchscikit-image>=0.18.0
opencv-python>=4.5.0jupyter>=1.0.0
ipython>=7.0.0- Clone the repository:
git clone https://github.com/username/Pattern-Recognition.git
cd Pattern-Recognition- Set up Python environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt # Create requirements.txt with above dependencies- Verify installation:
python Test/sample.pyAssignment 1 - Basic Classifiers:
cd 1/
python perceptron.py
python knn.py
python document_classification.pyAssignment 2 - Evaluation Metrics:
cd 2/
python metrics.pyAssignment 3 - Logistic Regression:
cd 3/
python logistic.py
python classifier.pyAssignment 4 - Feature Engineering:
cd 4/
python data_loader.py
python feature.py
python boundary.pyAssignment 6 - Deep Learning:
cd 6/
jupyter notebook latent.ipynb
jupyter notebook segment.ipynb# Example: Using k-NN classifier
from knn import KNNClassifier
# Initialize classifier
knn = KNNClassifier(k=5)
# Train the model
knn.train(X_train, y_train)
# Make predictions
predictions = knn.predict(X_test)# Example: Using evaluation metrics
from metrics import Metrics
# Calculate performance metrics
accuracy = Metrics.accuracy(y_true, y_pred)
precision = Metrics.precision(y_true, y_pred)
recall = Metrics.recall(y_true, y_pred)
f1 = Metrics.f1_score(y_true, y_pred)By working through these assignments, you will gain experience with:
- Classical Machine Learning: Perceptron, k-NN, logistic regression
- Evaluation Techniques: Cross-validation, ROC analysis, statistical testing
- Feature Engineering: Image processing, gradient features, texture analysis
- Deep Learning: Autoencoders, CNNs, segmentation networks
- Computer Vision: Image restoration, medical image analysis
- Software Engineering: Clean code practices, modular design
The implementations cover real-world applications including:
- MNIST Digit Recognition: Achieving competitive accuracy with basic classifiers
- Document Classification: Text analysis using natural language processing
- Medical Image Segmentation: Automated polyp detection in endoscopic images
- Image Restoration: Denoising and deblurring using deep learning
- Boundary Detection: Edge detection in natural images
This repository is primarily for educational purposes. If you find bugs or have suggestions for improvements:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Parth Shandilya
- Course instructors and teaching assistants
- University Pattern Recognition course materials
- Open-source libraries and datasets used throughout the projects