Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14155

How to display images with google facets dive?

$
0
0

I am getting started with google facets, but I am finding the documentation insufficient.

I want to use facets dive to visualize images like they do here for cifar-10 . There is another example here using the Quick, draw! dataset.

However, I cannot find how to set it up.

That is about what I have so far, the code works all right:

from sklearn.datasets import fetch_mldatafrom sklearn.decomposition import PCAimport pandas as pdimport numpy as npfrom IPython.core.display import display, HTML#load data:mnist = fetch_mldata("MNIST original")idx =np.random.randint(70000, 1000) #get random 1000 samplesX = mnist.data[idx]/255.0y = mnist.target[idx]#dimensionality reduction to get 3 featurespca = PCA(n_components=3)pca_result = pca.fit_transform(X)#put everything in a dataframedf = df_pca = pd.DataFrame(data = pca_result, columns = [["pca-one", "pca-two", "pca-three"]])df['y'] = y#display facets divejsonstr = df.to_json(orient='records')HTML_TEMPLATE = """<link rel="import" href="https://raw.githubusercontent.com/PAIR-code/facets/master/facets-dist/facets-jupyter.html"><facets-dive id="elem" height="600"></facets-dive><script>          var data = {jsonstr};          document.querySelector("#elem").data = data;</script>"""html = HTML_TEMPLATE.format(jsonstr=jsonstr)display(HTML(html))

This script works fine, but I just get circles with the labels (or whichever feature I choose), but I don't see how to integrate the actual images in there. The only hint I have so far is that I need the facets_atlasmaker for that, but I found the documentation rather insufficient.

If something is not clear, please let me know in the comments, I can try do add more relevant information then.


Viewing all articles
Browse latest Browse all 14155

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>