-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
202 additions
and
25 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"\nApplying ivis to the MNIST dataset\n==================================\n\nIvis can be applied easily applied to unstructured datasets, including images.\nHere we visualise the MNSIT digits dataset using two-dimensional ivis\nembeddings.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\nimport matplotlib.pyplot as plt\n\nfrom sklearn.datasets import fetch_openml\nfrom ivis import Ivis\n\nmnist = fetch_openml('mnist_784', version=1)\n\nivis = Ivis(model='maaten', verbose=0)\nembeddings = ivis.fit_transform(mnist.data)\n\ncolor = mnist.target.astype(int)\n\nplt.figure(figsize=(8, 8), dpi=150)\nplt.scatter(x=embeddings[:, 0],\n y=embeddings[:, 1], c=color, cmap=\"Spectral\", s=0.1)\nplt.xlabel('ivis 1')\nplt.ylabel('ivis 2')\nplt.show()\n\nos.remove('annoy.index')" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Applying ivis to the MNIST dataset | ||
================================== | ||
Ivis can be applied easily applied to unstructured datasets, including images. | ||
Here we visualise the MNSIT digits dataset using two-dimensional ivis | ||
embeddings. | ||
""" | ||
|
||
import os | ||
import matplotlib.pyplot as plt | ||
|
||
from sklearn.datasets import fetch_openml | ||
from ivis import Ivis | ||
|
||
mnist = fetch_openml('mnist_784', version=1) | ||
|
||
ivis = Ivis(model='maaten', verbose=0) | ||
embeddings = ivis.fit_transform(mnist.data) | ||
|
||
color = mnist.target.astype(int) | ||
|
||
plt.figure(figsize=(8, 8), dpi=150) | ||
plt.scatter(x=embeddings[:, 0], | ||
y=embeddings[:, 1], c=color, cmap="Spectral", s=0.1) | ||
plt.xlabel('ivis 1') | ||
plt.ylabel('ivis 2') | ||
plt.show() | ||
|
||
os.remove('annoy.index') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
.. note:: | ||
:class: sphx-glr-download-link-note | ||
|
||
Click :ref:`here <sphx_glr_download_auto_examples_mnist.py>` to download the full example code | ||
.. rst-class:: sphx-glr-example-title | ||
|
||
.. _sphx_glr_auto_examples_mnist.py: | ||
|
||
|
||
Applying ivis to the MNIST dataset | ||
================================== | ||
|
||
Ivis can be applied easily applied to unstructured datasets, including images. | ||
Here we visualise the MNSIT digits dataset using two-dimensional ivis | ||
embeddings. | ||
|
||
.. code-block:: default | ||
import os | ||
import matplotlib.pyplot as plt | ||
from sklearn.datasets import fetch_openml | ||
from ivis import Ivis | ||
mnist = fetch_openml('mnist_784', version=1) | ||
ivis = Ivis(model='maaten', verbose=0) | ||
embeddings = ivis.fit_transform(mnist.data) | ||
color = mnist.target.astype(int) | ||
plt.figure(figsize=(8, 8), dpi=150) | ||
plt.scatter(x=embeddings[:, 0], | ||
y=embeddings[:, 1], c=color, cmap="Spectral", s=0.1) | ||
plt.xlabel('ivis 1') | ||
plt.ylabel('ivis 2') | ||
plt.show() | ||
os.remove('annoy.index') | ||
.. rst-class:: sphx-glr-timing | ||
|
||
**Total running time of the script:** ( 0 minutes 0.000 seconds) | ||
|
||
|
||
.. _sphx_glr_download_auto_examples_mnist.py: | ||
|
||
|
||
.. only :: html | ||
.. container:: sphx-glr-footer | ||
:class: sphx-glr-footer-example | ||
.. container:: sphx-glr-download | ||
:download:`Download Python source code: mnist.py <mnist.py>` | ||
.. container:: sphx-glr-download | ||
:download:`Download Jupyter notebook: mnist.ipynb <mnist.ipynb>` | ||
.. only:: html | ||
|
||
.. rst-class:: sphx-glr-signature | ||
|
||
`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters