GithubHelp home page GithubHelp logo

berkerdemirel / umap Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 887 KB

Implementation of UMAP dimensionality reduction algorithm in Python

Python 100.00%
dimensionality-reduction mnist python umap

umap's Introduction

UMAP

Uniform Manifold Approximation and Projection (UMAP) is an algorithm for dimensionality reduction which tries to preserve the local distances that the data has in the original dimension. like t-SNE and Isomap. This repository provides an implementation of UMAP dimensionality reduction algorithm in Python from scratch.

Main components of the algorithm are as follows

  • Finding K-nearest neighbors with their corresponding distances in the original data.
  • Using K-nearest neighbor graph, constructing a fuzzy simplicial set.
  • Initializing the low-dimensional embeddings with a reasonable start.
  • Optimizing the low-dimensional embeddings using the fuzzy simplicial set constructed from original data.

Dependencies

cd PROJECT_PATH
pip -r requirements.txt

Example Usage

import UMAP
X, y = load_digits(return_X_y=True)
mp = UMAP(n_components=n_components, 
                n_neighbors=n_neighbors, 
                metric=metric, 
                n_epochs=n_epochs, 
                learning_rate=learning_rate, 
                init_symbol=init, 
                min_dist=min_dist, 
                spread=spread, 
                set_operation_ratio=set_operation_ratio, 
                local_connectivity=local_connectivity, 
                repulsion_strength=repulsion_strength, 
                neg_sample_rate=neg_sample_rate, 
                a=a, 
                b=b
            )
y_pred = mp.fit_transform(X)
fig, ax = plt.subplots(figsize=(12, 10))
color = y
plt.scatter(y_pred[:,0], y_pred[:,1], c=color, cmap="Spectral", s=2)
plt.setp(ax, xticks=[], yticks=[])
plt.title("Data embedded into two dimensions", fontsize=18)
plt.savefig("./reduced_data.png")

Figures on MNIST and Load Digits Datasets

MNIST

Dimensionality Reduction on MNIST

Load Digits

Dimensionality Reduction on Load Digits

References

[1] L. McInnes, J. Healy, and J. Melville, "Umap: Uniform manifold approximation and projection for dimension reduction," arXiv preprint arXiv:1802.03426, 2018.

umap's People

Contributors

berkerdemirel avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.