Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

t-SNE Visualization on MNIST Dataset Python scikit-learn seaborn JupyterView on Kaggle


🚀 Live Results

You can view the notebook with all outputs and results on Kaggle:
https://www.kaggle.com/code/evangelosgakias/t-sne-mnist-dataset


📑 Table of Contents


📝 Overview

This project demonstrates the application of t-Distributed Stochastic Neighbor Embedding (t-SNE) for visualizing high-dimensional data, using the MNIST handwritten digits dataset. The notebook covers the full data science workflow: data loading, preprocessing, dimensionality reduction, visualization, and interpretation of results.

Goal:
Project high-dimensional MNIST data into 2D space to reveal clusters and patterns, and to compare t-SNE with other dimensionality reduction techniques.


🏗️ Project Structure

t-Distributed Stochastic Neighbor Embedding/
├── t_sne_project.ipynb      # Jupyter notebook with the complete implementation
├── requirements.txt         # Python dependencies
├── README.md                # Project documentation (this file)
├── figures/                 # Result images and plots
│   ├── sample_digits.png
│   ├── class_distribution.png
│   ├── tsne_embedding.png
│   ├── tsne_perplexity_5.png
│   └── tsne_different_perplexities.png

🚦 Features

Data Preparation

  • Dataset Loading: Uses the MNIST dataset (70,000 samples, 784 features).
  • Exploratory Data Analysis (EDA): Sample digit visualization, class distribution.
  • Preprocessing: Standard scaling, subsetting for computational efficiency.

Dimensionality Reduction & Visualization

  • t-SNE: 2D embedding of MNIST data, parameter tuning (perplexity).
  • Visualization: Scatter plots of t-SNE embeddings, color-coded by digit label.
  • Parameter Exploration: Visual comparison of t-SNE results for different perplexity values.

Interpretation & Discussion

  • Cluster Analysis: Discussion of cluster structure, separation, and intra-class variation.
  • Comparison: Theoretical discussion of t-SNE vs. PCA.

⚡ Quickstart

  1. Kaggle (Recommended for Reproducibility):
  2. Local:
    • Clone the repo and run t_sne_project.ipynb in Jupyter after installing requirements.

💻 Usage

  1. 📥 Clone the repository:
    git clone https://github.com/EvanGks/t-sne-mnist-visualization.git
    cd t-sne-mnist-visualization
  2. 🔒 Create and activate a virtual environment:
    • Windows:
      python -m venv .venv
      .venv\Scripts\activate
    • macOS/Linux:
      python3 -m venv .venv
      source .venv/bin/activate
  3. 📦 Install dependencies:
    pip install -r requirements.txt
  4. 🚀 Launch Jupyter Notebook:
    jupyter notebook t_sne_project.ipynb
  5. ▶️ Run all cells to reproduce the analysis and results.

🛠️ Troubleshooting:

  • If you encounter missing package errors, ensure your Python environment is activated and up to date.
  • For best reproducibility, use the provided Kaggle link.

📊 Results

Visualizations

  • Sample Digits:
    Sample Digits
  • Class Distribution:
    Class Distribution
  • t-SNE Embedding (Perplexity=30):
    t-SNE Embedding
  • t-SNE with Different Perplexities:
    tsne different perplexities

Key Findings

  • t-SNE reveals clear clusters corresponding to digit classes in the MNIST dataset.
  • The choice of perplexity significantly affects the visualization; values between 30 and 50 often yield the best separation for MNIST.
  • Some digits (e.g., 4 and 9, 3 and 8) may have overlapping clusters due to visual similarity.
  • t-SNE excels at local structure but does not always preserve global distances.

For full details, metrics, and plots, see the notebook.


📝 Limitations and Future Work

  • Computational Cost: t-SNE is slow for large datasets; subsetting is used for efficiency.
  • Parameter Sensitivity: Results depend on perplexity and other parameters.
  • Global Structure: t-SNE is best for local structure; global distances may be misleading.
  • Potential Improvements:
    • Compare with UMAP and PCA visually and quantitatively.
    • Automate parameter selection.
    • Apply to other high-dimensional datasets.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue for suggestions and improvements.


📝 License

This project is licensed under the MIT License. See the LICENSE file for details.


📬 Contact

For questions or feedback, please reach out via:


Happy Visualizing!

About

A comprehensive end-to-end project demonstrating t-Distributed Stochastic Neighbor Embedding (t-SNE) for visualizing high-dimensional data using the MNIST handwritten digits dataset. Includes data preprocessing, parameter exploration, and insightful visualizations.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages