{
  "id": 191269,
  "title": "Visualisation using Manifold Learning approach for dimensionality reduction using sklearn.manifold.Isomap",
  "url": "/competitions/digit-recognizer/discussion/191269",
  "author_name": "Archit Singh",
  "post_date": "2020-10-15T15:34:42.727000",
  "votes": 0,
  "comment_count": 0,
  "views": null,
  "content": "<h1>Manifold Learning</h1>\n<p>Manifold learning is an approach to <strong>non-linear dimensionality reduction</strong>. Algorithms for this task are based on the idea that the dimensionality of many data sets is only artificially high, which can be <strong>reduced for a better perception of the visualization</strong>.</p>\n<h1>Use Case of Manifold Learning</h1>\n<p>High-dimensional datasets can be very difficult to visualize. While data in two or three dimensions can be plotted to show the inherent structure of the data, equivalent high-dimensional plots are much less intuitive. <strong>To aid visualization of the structure of a dataset, the dimension must be reduced in some way.</strong></p>\n<h1>Solution to the Use Case</h1>\n<p>To address this concern, a number of supervised and unsupervised linear dimensionality reduction frameworks have been designed, such as Principal Component Analysis (PCA), Independent Component Analysis, Linear Discriminant Analysis, and others. These algorithms define specific rubrics to choose an “interesting” linear projection of the data. <strong>These methods can be powerful, but often miss important non-linear structure in the data.</strong></p>\n<h1>How Manifold Learning helps</h1>\n<p><em>Manifold Learning</em> can be thought of as an attempt to generalize linear frameworks like PCA to be <strong>sensitive to non-linear structures in data</strong>. <br>\nThe typical manifold learning problem is <em>unsupervised</em></p>\n<h1>A Simple Example</h1>\n<p>This example uses <code>sklearn.manifold.Isomap</code> (Manifold Learning), <code>plt.scatter</code> (Visualisation) and <code>sklearn.datasets.load_digits</code> (Dataset)</p>\n<h3>Import and load the dataset</h3>\n<pre><code>from sklearn.datasets import load_digits\ndigits = load_digits(n_class=6)\n</code></pre>\n<p>This data is included in Scikit-Learn and consists of nearly 2,000 8×8 thumbnails showing various handwritten digits.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fa7a3060c591455d61ab91d745d083403%2Frsz_screenshot_from_2020-10-15_20-44-58.jpg?generation=1602775673434524&amp;alt=media\" alt=\"\"></p>\n<h3>Project the digits into 2 dimensions using IsoMap</h3>\n<pre><code>from sklearn.manifold import Isomap\niso = Isomap(n_components=2)\nprojection = iso.fit_transform(digits.data)\n</code></pre>\n<p>projection variable will contain the entire dataset transformed into (x,y) two dimensions.<br>\nanother way of thinking about it is that every row in the dataset (with 784 features)will be converted to (x, y) (2 features)</p>\n<h3>Plot the results</h3>\n<pre><code>plt.scatter(projection[:, 0], projection[:, 1], lw=0.1,\nc=digits.target, cmap=plt.cm.get_cmap('cubehelix', 6))\nplt.colorbar(ticks=range(6), label='digit value')\nplt.clim(-0.5, 5.5)\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fda647e17a79a27c9b9e7105d61aed7fd%2Frsz_screenshot_from_2020-10-15_20-55-49.jpg?generation=1602776016860931&amp;alt=media\" alt=\"\"></p>\n<p>In the figure, <em>every data point</em> with <em>784 features</em> was converted to a <em>data point with 2 features</em> (x,y) and plotted in a scatter plot using matplotlib.</p>\n<p>We can clearly see how powerful manifold learning is. It has many more use cases where you can apply it.<br>\nJust remember: <strong>a Higher Number of Features can be squished together in a meaningful way in aid of our visualization or any other use case.</strong></p>\n<blockquote>\n  <h3>Words of Wisdom</h3>\n  <p>Look for the bare necessities<br>\n  The simple bare necessities<br>\n  Forget about your worries and your strife<br>\n  I mean the bare necessities<br>\n  Old Mother Nature’s recipes<br>\n  That bring the bare necessities of life</p>\n  <p>– Baloo’s song [The Jungle Book]</p>\n</blockquote>\n<p>Ref: <a href=\"https://scikit-learn.org/stable/modules/manifold.html\" target=\"_blank\">https://scikit-learn.org/stable/modules/manifold.html</a></p>",
  "messages": [
    {
      "id": 1050625,
      "postDate": "2020-10-15T15:34:42.727Z",
      "content": "<h1>Manifold Learning</h1>\n<p>Manifold learning is an approach to <strong>non-linear dimensionality reduction</strong>. Algorithms for this task are based on the idea that the dimensionality of many data sets is only artificially high, which can be <strong>reduced for a better perception of the visualization</strong>.</p>\n<h1>Use Case of Manifold Learning</h1>\n<p>High-dimensional datasets can be very difficult to visualize. While data in two or three dimensions can be plotted to show the inherent structure of the data, equivalent high-dimensional plots are much less intuitive. <strong>To aid visualization of the structure of a dataset, the dimension must be reduced in some way.</strong></p>\n<h1>Solution to the Use Case</h1>\n<p>To address this concern, a number of supervised and unsupervised linear dimensionality reduction frameworks have been designed, such as Principal Component Analysis (PCA), Independent Component Analysis, Linear Discriminant Analysis, and others. These algorithms define specific rubrics to choose an “interesting” linear projection of the data. <strong>These methods can be powerful, but often miss important non-linear structure in the data.</strong></p>\n<h1>How Manifold Learning helps</h1>\n<p><em>Manifold Learning</em> can be thought of as an attempt to generalize linear frameworks like PCA to be <strong>sensitive to non-linear structures in data</strong>. <br>\nThe typical manifold learning problem is <em>unsupervised</em></p>\n<h1>A Simple Example</h1>\n<p>This example uses <code>sklearn.manifold.Isomap</code> (Manifold Learning), <code>plt.scatter</code> (Visualisation) and <code>sklearn.datasets.load_digits</code> (Dataset)</p>\n<h3>Import and load the dataset</h3>\n<pre><code>from sklearn.datasets import load_digits\ndigits = load_digits(n_class=6)\n</code></pre>\n<p>This data is included in Scikit-Learn and consists of nearly 2,000 8×8 thumbnails showing various handwritten digits.</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fa7a3060c591455d61ab91d745d083403%2Frsz_screenshot_from_2020-10-15_20-44-58.jpg?generation=1602775673434524&amp;alt=media\" alt=\"\"></p>\n<h3>Project the digits into 2 dimensions using IsoMap</h3>\n<pre><code>from sklearn.manifold import Isomap\niso = Isomap(n_components=2)\nprojection = iso.fit_transform(digits.data)\n</code></pre>\n<p>projection variable will contain the entire dataset transformed into (x,y) two dimensions.<br>\nanother way of thinking about it is that every row in the dataset (with 784 features)will be converted to (x, y) (2 features)</p>\n<h3>Plot the results</h3>\n<pre><code>plt.scatter(projection[:, 0], projection[:, 1], lw=0.1,\nc=digits.target, cmap=plt.cm.get_cmap('cubehelix', 6))\nplt.colorbar(ticks=range(6), label='digit value')\nplt.clim(-0.5, 5.5)\n</code></pre>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fda647e17a79a27c9b9e7105d61aed7fd%2Frsz_screenshot_from_2020-10-15_20-55-49.jpg?generation=1602776016860931&amp;alt=media\" alt=\"\"></p>\n<p>In the figure, <em>every data point</em> with <em>784 features</em> was converted to a <em>data point with 2 features</em> (x,y) and plotted in a scatter plot using matplotlib.</p>\n<p>We can clearly see how powerful manifold learning is. It has many more use cases where you can apply it.<br>\nJust remember: <strong>a Higher Number of Features can be squished together in a meaningful way in aid of our visualization or any other use case.</strong></p>\n<blockquote>\n  <h3>Words of Wisdom</h3>\n  <p>Look for the bare necessities<br>\n  The simple bare necessities<br>\n  Forget about your worries and your strife<br>\n  I mean the bare necessities<br>\n  Old Mother Nature’s recipes<br>\n  That bring the bare necessities of life</p>\n  <p>– Baloo’s song [The Jungle Book]</p>\n</blockquote>\n<p>Ref: <a href=\"https://scikit-learn.org/stable/modules/manifold.html\" target=\"_blank\">https://scikit-learn.org/stable/modules/manifold.html</a></p>",
      "rawMarkdown": "# Manifold Learning\nManifold learning is an approach to **non-linear dimensionality reduction**. Algorithms for this task are based on the idea that the dimensionality of many data sets is only artificially high, which can be **reduced for a better perception of the visualization**.\n\n# Use Case of Manifold Learning\nHigh-dimensional datasets can be very difficult to visualize. While data in two or three dimensions can be plotted to show the inherent structure of the data, equivalent high-dimensional plots are much less intuitive. **To aid visualization of the structure of a dataset, the dimension must be reduced in some way.**\n\n# Solution to the Use Case\nTo address this concern, a number of supervised and unsupervised linear dimensionality reduction frameworks have been designed, such as Principal Component Analysis (PCA), Independent Component Analysis, Linear Discriminant Analysis, and others. These algorithms define specific rubrics to choose an “interesting” linear projection of the data. **These methods can be powerful, but often miss important non-linear structure in the data.**\n\n# How Manifold Learning helps\n*Manifold Learning* can be thought of as an attempt to generalize linear frameworks like PCA to be **sensitive to non-linear structures in data**. \nThe typical manifold learning problem is *unsupervised*\n\n# A Simple Example \nThis example uses `sklearn.manifold.Isomap` (Manifold Learning), `plt.scatter` (Visualisation) and `sklearn.datasets.load_digits` (Dataset)\n\n### Import and load the dataset\n```\nfrom sklearn.datasets import load_digits\ndigits = load_digits(n_class=6)\n```\nThis data is included in Scikit-Learn and consists of nearly 2,000 8×8 thumbnails showing various handwritten digits.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fa7a3060c591455d61ab91d745d083403%2Frsz_screenshot_from_2020-10-15_20-44-58.jpg?generation=1602775673434524&alt=media)\n\n### Project the digits into 2 dimensions using IsoMap\n```\nfrom sklearn.manifold import Isomap\niso = Isomap(n_components=2)\nprojection = iso.fit_transform(digits.data)\n```\nprojection variable will contain the entire dataset transformed into (x,y) two dimensions.\nanother way of thinking about it is that every row in the dataset (with 784 features)will be converted to (x, y) (2 features)\n\n### Plot the results\n```\nplt.scatter(projection[:, 0], projection[:, 1], lw=0.1,\nc=digits.target, cmap=plt.cm.get_cmap('cubehelix', 6))\nplt.colorbar(ticks=range(6), label='digit value')\nplt.clim(-0.5, 5.5)\n```\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fda647e17a79a27c9b9e7105d61aed7fd%2Frsz_screenshot_from_2020-10-15_20-55-49.jpg?generation=1602776016860931&alt=media)\n\nIn the figure, *every data point* with *784 features* was converted to a *data point with 2 features* (x,y) and plotted in a scatter plot using matplotlib.\n\nWe can clearly see how powerful manifold learning is. It has many more use cases where you can apply it.\nJust remember: **a Higher Number of Features can be squished together in a meaningful way in aid of our visualization or any other use case.**\n\n> ### Words of Wisdom\n> Look for the bare necessities\n> The simple bare necessities\n> Forget about your worries and your strife\n> I mean the bare necessities\n> Old Mother Nature’s recipes\n> That bring the bare necessities of life\n\n> – Baloo’s song [The Jungle Book]\n\nRef: https://scikit-learn.org/stable/modules/manifold.html"
    }
  ],
  "comments": [],
  "raw_markdown_by_id": {
    "1050625": "# Manifold Learning\nManifold learning is an approach to **non-linear dimensionality reduction**. Algorithms for this task are based on the idea that the dimensionality of many data sets is only artificially high, which can be **reduced for a better perception of the visualization**.\n\n# Use Case of Manifold Learning\nHigh-dimensional datasets can be very difficult to visualize. While data in two or three dimensions can be plotted to show the inherent structure of the data, equivalent high-dimensional plots are much less intuitive. **To aid visualization of the structure of a dataset, the dimension must be reduced in some way.**\n\n# Solution to the Use Case\nTo address this concern, a number of supervised and unsupervised linear dimensionality reduction frameworks have been designed, such as Principal Component Analysis (PCA), Independent Component Analysis, Linear Discriminant Analysis, and others. These algorithms define specific rubrics to choose an “interesting” linear projection of the data. **These methods can be powerful, but often miss important non-linear structure in the data.**\n\n# How Manifold Learning helps\n*Manifold Learning* can be thought of as an attempt to generalize linear frameworks like PCA to be **sensitive to non-linear structures in data**. \nThe typical manifold learning problem is *unsupervised*\n\n# A Simple Example \nThis example uses `sklearn.manifold.Isomap` (Manifold Learning), `plt.scatter` (Visualisation) and `sklearn.datasets.load_digits` (Dataset)\n\n### Import and load the dataset\n```\nfrom sklearn.datasets import load_digits\ndigits = load_digits(n_class=6)\n```\nThis data is included in Scikit-Learn and consists of nearly 2,000 8×8 thumbnails showing various handwritten digits.\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fa7a3060c591455d61ab91d745d083403%2Frsz_screenshot_from_2020-10-15_20-44-58.jpg?generation=1602775673434524&alt=media)\n\n### Project the digits into 2 dimensions using IsoMap\n```\nfrom sklearn.manifold import Isomap\niso = Isomap(n_components=2)\nprojection = iso.fit_transform(digits.data)\n```\nprojection variable will contain the entire dataset transformed into (x,y) two dimensions.\nanother way of thinking about it is that every row in the dataset (with 784 features)will be converted to (x, y) (2 features)\n\n### Plot the results\n```\nplt.scatter(projection[:, 0], projection[:, 1], lw=0.1,\nc=digits.target, cmap=plt.cm.get_cmap('cubehelix', 6))\nplt.colorbar(ticks=range(6), label='digit value')\nplt.clim(-0.5, 5.5)\n```\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5850041%2Fda647e17a79a27c9b9e7105d61aed7fd%2Frsz_screenshot_from_2020-10-15_20-55-49.jpg?generation=1602776016860931&alt=media)\n\nIn the figure, *every data point* with *784 features* was converted to a *data point with 2 features* (x,y) and plotted in a scatter plot using matplotlib.\n\nWe can clearly see how powerful manifold learning is. It has many more use cases where you can apply it.\nJust remember: **a Higher Number of Features can be squished together in a meaningful way in aid of our visualization or any other use case.**\n\n> ### Words of Wisdom\n> Look for the bare necessities\n> The simple bare necessities\n> Forget about your worries and your strife\n> I mean the bare necessities\n> Old Mother Nature’s recipes\n> That bring the bare necessities of life\n\n> – Baloo’s song [The Jungle Book]\n\nRef: https://scikit-learn.org/stable/modules/manifold.html"
  }
}