Git Product home page Git Product logo

Comments (3)

erdogant avatar erdogant commented on May 22, 2024

Is your suggestion to only return fig and not ax?

from flameplot.

BrandonKMLee avatar BrandonKMLee commented on May 22, 2024

Current edit might makes things clearer, it might be good to always return fig and ax, and have the documentation match the standard output.

!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.to_numpy())

def scatter_maker(transformed, title, labels=y['country']):
  fig1, _ = scatter(transformed[:,0], transformed[:,1], labels=y, s=75, title=title)
  # documentation claimed there is only `(fig)` and not `(fig, ax)`
  # https://github.com/erdogant/scatterd/blob/master/scatterd/scatterd.py#L156
  # https://github.com/erdogant/flameplot/blob/master/flameplot/flameplot.py#L161
  fig1.savefig(title+'_2D.png')
  pass

def compare_maker(transformed, title, pca_standard=pca_standard):
  scores = compare(pca_standard, transformed, n_steps=5)
  fig2 = plot(scores, xlabel='PCA', ylabel=title) # not follow the `(fig, ax)` design pattern
  # https://github.com/erdogant/imagesc/blob/master/imagesc/imagesc.py#L243
  # https://github.com/erdogant/flameplot/blob/master/flameplot/flameplot.py#L138
  fig2.savefig(title+'_factors.png')
  pass

for i in mapper:
  title = type(i).__name__ # name of the object class
  transformed = i.fit_transform(X.to_numpy())
  # to_numpy is needed for TriMAP and PaCMAP
  scatter_maker(transformed, title, y)
  compare_maker(transformed, title, pca_standard=pca_standard)

from flameplot.

erdogant avatar erdogant commented on May 22, 2024

Agree. The output is now (fig, ax) and is also changed in the documentation pages.

Update to the latest version with:

pip install -U flameplot

from flameplot.

Related Issues (2)

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.