Giter Club home page Giter Club logo

flameplot's Introduction

Python PyPI Version License Github Forks GitHub Open Issues Project Status Downloads Downloads DOI Sphinx Medium

Flameplot - Comparison of (high) dimensional embeddings.

⭐️ Star this repo if you like it ⭐️

Medium Blog

Also checkout The Similarity between t-SNE, UMAP, PCA, and Other Mappings to get a structured overview and usage of flameplot.

Method

To compare the embedding of samples in two different maps, we propose a scale dependent similarity measure. For a pair of maps X and Y, we compare the sets of the, respectively, kx and ky nearest neighbours of each sample. We first define the variable rxij as the rank of the distance of sample j among all samples with respect to sample i, in map X. The nearest neighbor of sample i will have rank 1, the second nearest neighbor rank 2, etc. Analogously, ryij is the rank of sample j with respect to sample i in map Y. Now we define a score on the interval [0, 1], as (eq. 1)

where the variable n is the total number of samples, and the indicator function is given by (eq. 2)

The score sx,y(kx, ky) will have value 1 if, for each sample, all kx nearest neighbours in map X are also the ky nearest neighbours in map Y, or vice versa. Note that a local neighborhood of samples can be set on the minimum number of samples in the class. Alternatively, kxy can be also set on the average class size.

Schematic overview

Schematic overview to systematically compare local and global differences between two sample projections. For illustration we compare two input maps (x and y) in which each map contains n samples (step 1). The second step is the ranking of samples based on Euclidean distance. The ranks of map x are subsequently compared to the ranks of map y for kx and ky nearest neighbours (step 3). The overlap between ranks (step 4), is subsequently summarized in Score: Sx,y(kx,ky).

Functions in flameplot

scores = flameplot.compare(map1, map2)
fig    = flameplot.plot(scores)
X,y    = flameplot.import_example()
fig    = flameplot.scatter(Xcoord,Ycoord)

Install flameplot from PyPI

pip install flameplot

Import flameplot package

import flameplot as flameplot

On the documentation pages you can find detailed information about the working of the flameplot with examples.


Examples



Support

This project needs some love! ❤️ You can help in various ways.

* Become a Sponsor!
* Star this repo at the github page.
* Other contributions can be in the form of feature requests, idea discussions, reporting bugs, opening pull requests.
* Read more why becoming an sponsor is important on the Sponsor Github Page.

Cheers Mate.

References

flameplot's People

Contributors

erdogant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flameplot's Issues

Documentation Inconsistency

Currently flameplot only provides a "fig" as a tuple of fig (plot) and ax
https://github.com/erdogant/flameplot/blob/master/flameplot/flameplot.py#L161

But the tuple contains the real fig (plot) and ax
https://github.com/erdogant/scatterd/blob/master/scatterd/scatterd.py#L156

For purposes of saving graphs, this could be fixed.

For testing (given a proper X):

!pip install umap-learn trimap pacmap
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from umap import UMAP # https://github.com/lmcinnes/umap
from trimap import TRIMAP # https://github.com/eamid/trimap
from pacmap import PaCMAP # https://github.com/YingfanWang/PaCMAP

k = 3
mapper = [TSNE(n_components=k), 
  # UMAP(n_components=k),
  # TRIMAP(n_dims=k),
  PaCMAP(n_components=k)
]

from flameplot import scatter, compare, plot

pca_standard = PCA().fit_transform(X)

for i in mapper:
  title = type(i).__name__ # name of the object class
  transformed = i.fit_transform(X)
  fig, _ = scatter(transformed[:,0], transformed[:,1], labels=y['country'], s=75, title=title)
  fig.savefig(title+'_2D.png')
  scores = compare(pca_standard, transformed, n_steps=5)
  fig, _ = plot(scores, xlabel='PCA', ylabel=title)
  fig.savefig(title+'_factors.png')

Module Import Error

I installed via pip install flameplot and called import flameplot and had gotten an error ModuleNotFoundError: No module named 'requests'. Manually installing requests resolves this issue.

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.