<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/manifold-visualization-second-example/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://matloff.wordpress.com/2018/10/01/manifold-visualization-second-example/"> Mad (Data) Scientist</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In <a rel="nofollow" href="https://matloff.wordpress.com/2018/09/30/manifold-visualization-polynomials-to-the-rescue/" target="_blank">last night’s post</a>, I introduced <strong>prVis()</strong>, a new visualization tool which we have invented, available in our <strong>polyreg</strong> package. Recall that <strong>prVis()</strong> is intended as a simpler alternative to recent visualization tools like t-SNE and UMAP. Here I will post another example.</p>
<p>The dataset is prgeng, included in the package. It consists of wage income, age, gender, and so on, of Silicon Valley programmers and engineers, from the 2000 Census. We first load the data and then choose some of the variables (age, gender, education and occupation):</p>
<pre>getPE()
pe1 &lt;- pe[,c(1,2,6:7,12:16)]</pre>
<p>So, let’s plot the graph:</p>
<p><a rel="nofollow" href="https://matloff.files.wordpress.com/2018/10/peprv.png" target="_blank"><img data-orig-file="https://matloff.files.wordpress.com/2018/10/peprv.png" data-orig-size="480,480" data-medium-file="https://matloff.files.wordpress.com/2018/10/peprv.png?w=300&amp;h=300&amp;fit=300%2C300&amp;resize=300%2C300" data-attachment-id="2114" data-image-meta="{" data-image-description="" src="https://matloff.files.wordpress.com/2018/10/peprv.png?w=300&h=300&fit=300%2C300&resize=300%2C300" data-permalink="https://matloff.wordpress.com/2018/10/01/manifold-visualization-second-example/peprv/" data-large-file="https://matloff.files.wordpress.com/2018/10/peprv.png?w=474" alt="" data-image-title="PEprv" sizes="(max-width: 300px) 100vw, 300px" width="300" data-comments-opened="1" class="wp-image-2114" data-recalc-dims="1" height="300"></a></p>
<p>The graph consists of streaks, about a dozen of them. What do they represent? To investigate that question, we call another <strong>polyreg</strong> function:</p>
<p>addRowNums(16,z)</p>
<p>This will write the row numbers of 16 random points from the dataset onto the graph that I just plotted, which now looks like this:</p>
<p><a rel="nofollow" href="https://matloff.files.wordpress.com/2018/10/peprvrows.png" target="_blank"><img data-orig-file="https://matloff.files.wordpress.com/2018/10/peprvrows.png" data-orig-size="480,480" data-medium-file="https://matloff.files.wordpress.com/2018/10/peprvrows.png?w=300&amp;h=300&amp;fit=300%2C300&amp;resize=300%2C300" data-attachment-id="2115" data-image-meta="{" data-image-description="" src="https://matloff.files.wordpress.com/2018/10/peprvrows.png?w=300&h=300&fit=300%2C300&resize=300%2C300" data-permalink="https://matloff.wordpress.com/2018/10/01/manifold-visualization-second-example/peprvrows/" data-large-file="https://matloff.files.wordpress.com/2018/10/peprvrows.png?w=474" alt="" data-image-title="PEprvRows" sizes="(max-width: 300px) 100vw, 300px" width="300" data-comments-opened="1" class="wp-image-2115" data-recalc-dims="1" height="300"></a></p>
<p>Due to overplotting, the numbers are difficult to read, but are also output to the R console:</p>
<p>[1] “highlighted rows:”<br>
[1] 2847<br>
[1] 5016<br>
[1] 5569<br>
[1] 6568<br>
[1] 6915<br>
[1] 8604<br>
[1] 9967<br>
[1] 10113<br>
[1] 10666<br>
[1] 10744<br>
[1] 11383<br>
[1] 11404<br>
[1] 11725<br>
[1] 13335<br>
[1] 14521<br>
[1] 15462</p>
<p>Rows 2847 and 10666 seem to be on the same streak, so they must have something in common. Let’s take a look.</p>
<blockquote>
<pre>> pe1[2847,]
         age sex ms phd occ1 occ2 occ3 occ4 occ5
2847 32.3253   1  1   0    0    0    0    0    0
> pe1[10666,]
          age sex ms phd occ1 occ2 occ3 occ4 occ5
10666 45.36755  1  1   0    0    0    0    0    0</pre>
</blockquote>
<p>Aha! Except for age, these two workers are identical in terms of gender (male), education (Master’s) and occupation (occ. category 6). Now those streaks make sense; each one represents a certain combination of the categorical variables.</p>
<p>Well, then, let’s see what UMAP does:</p>
<p>plot(umap(pe1))</p>
<p>The result is</p>
<p><a rel="nofollow" href="https://matloff.files.wordpress.com/2018/10/peumap.png" target="_blank"><img data-orig-file="https://matloff.files.wordpress.com/2018/10/peumap.png" data-orig-size="480,480" data-medium-file="https://matloff.files.wordpress.com/2018/10/peumap.png?w=300&amp;h=300&amp;fit=300%2C300&amp;resize=300%2C300" data-attachment-id="2116" data-image-meta="{" data-image-description="" src="https://matloff.files.wordpress.com/2018/10/peumap.png?w=300&h=300&fit=300%2C300&resize=300%2C300" data-permalink="https://matloff.wordpress.com/2018/10/01/manifold-visualization-second-example/peumap/" data-large-file="https://matloff.files.wordpress.com/2018/10/peumap.png?w=474" alt="" data-image-title="PEumap" sizes="(max-width: 300px) 100vw, 300px" width="300" data-comments-opened="1" class="wp-image-2116" data-recalc-dims="1" height="300"></a></p>
<p>The pattern here, if any, is not clear.</p>
<p>So in both examples, both last night’s and tonight’s, <strong>prVis()</strong> was not only simpler but also much more visually interpretable than UMAP.</p>
<p>In fairness, I must point out:</p>
<ul>
<li>I just used the default values of <strong>umap()</strong> in these examples. It would be interesting to explore other values. On the other hand, it may be that UMAP simply is not suitable for partially categorical data, as we have in this second example.</li>
<li>For most other datasets I’ve tried, <strong>prVis()</strong> and UMAP give similar results.</li>
</ul>
<p>Even so, these two points show the virtues of using <strong>prVis()</strong> . We are getting equal or better quality while not having to worry about settings for various hypeparameters.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://matloff.wordpress.com/2018/10/01/manifold-visualization-second-example/"> Mad (Data) Scientist</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/1WWYWT9w0sw" height="1"></a></div>