Skip to content

mineme0110/mnist

Repository files navigation

Machine Learning Examples

PyPI - Version PyPI - Python Version


Table of Contents

Setup

  1. Clone the repository:
git clone https://github.com/mineme0110/mnist.git
cd mnist
  1. Create virtual environment:
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

Models

MNIST Digit Classification

Neural network for MNIST digit classification using PyTorch.

  1. Install dependencies:
pip install -r requirements.txt
  1. Run the training script:
python src/mnist/train.py

Logistic Regression

Binary classification example using scikit-learn's Logistic Regression.

  1. Install dependencies:
pip install -r src/logistic-regression/requirements.txt
  1. Run the training script:
python src/logistic-regression/train.py

This will demonstrate logistic regression on a generated dataset with visualization of the decision boundary.

Content-Based Filtering

Movie recommendation system using content-based filtering.

  1. Install dependencies:
pip install -r src/content-based-filtering/requirements.txt
  1. Run the recommendation system:
python src/content-based-filtering/train.py

This will demonstrate movie recommendations based on content similarity using a sample movie dataset. The system considers movie genres, actors, and descriptions to make recommendations.

Example output:

Getting recommendations for: The Dark Knight
Recommended Movies:
------------------------------------------------------------
1. Iron Man
   Genres: Action, Adventure, Sci-Fi
   Similarity Score: 0.8245
------------------------------------------------------------
2. The Matrix
   Genres: Action, Sci-Fi
   Similarity Score: 0.7856

Fraud Detection

XGBoost-based fraud detection system for identifying fraudulent transactions.

Prerequisites for Mac users:

# Install OpenMP library (required for XGBoost)
brew install libomp

Simple Model

A basic fraud detection model with clear separation between normal and fraudulent transactions.

  1. Install dependencies:
pip install -r src/fraud-detection/requirements.txt
  1. Run the simple fraud detection model:
python src/fraud-detection/train_simple.py

Features:

  • Clear separation between classes
  • Basic XGBoost parameters
  • Perfect for understanding basic fraud detection concepts
  • Shows idealized probability distributions

Realistic Model

A more sophisticated model that better represents real-world fraud detection scenarios.

  1. Install dependencies (if not already installed):
pip install -r src/fraud-detection/requirements.txt
  1. Run the realistic fraud detection model:
python src/fraud-detection/train_realistic.py

Features:

  • Handles imbalanced classes
  • Uses realistic transaction patterns:
    • Transaction amounts
    • Time of day patterns
    • Geographic distances
    • Transaction frequency
  • Early stopping and validation
  • Feature importance analysis
  • More representative probability distributions

Example output:

Realistic Model Performance:
ROC AUC Score: 0.9985
Top 5 Most Important Features:
transaction_amount: 0.4532
time_of_day: 0.2876
distance_from_last: 0.1543
transaction_frequency: 0.0892
feature_5: 0.0157

License

This project is distributed under the terms of the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages