<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" >

<channel><title><![CDATA[Magic Analytics - Blog]]></title><link><![CDATA[http://www.magic-analytics.com/blog]]></link><description><![CDATA[Blog]]></description><pubDate>Tue, 22 Aug 2023 13:08:34 -0700</pubDate><generator>Weebly</generator><item><title><![CDATA[Using Git: The Solo Master]]></title><link><![CDATA[http://www.magic-analytics.com/blog/using-git-the-solo-master]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/using-git-the-solo-master#comments]]></comments><pubDate>Sun, 29 Oct 2017 05:11:08 GMT</pubDate><category><![CDATA[Git]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/using-git-the-solo-master</guid><description><![CDATA[Git is a very popular version control system for tracking changes in computer files and coordinating work on those files among multiple people (Wikipedia). It is well used in Data Science projects to keep track of code and maintain parallel development. Git can be used in a very complicated way, however, for Data Scientist, we can keep it simple. In this post, I am going to walk through the main use cases if you are a "Solo Master".   	 		 			 				 					 						  What is "Solo Master"?&#8203;When [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Git is a very popular version control system for tracking changes in computer files and coordinating work on those files among multiple people (Wikipedia). It is well used in Data Science projects to keep track of code and maintain parallel development. Git can be used in a very complicated way, however, for Data Scientist, we can keep it simple. In this post, I am going to walk through the main use cases if you are a "Solo Master".</div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:66.666666666667%; padding:0 15px;"> 					 						  <div class="paragraph"><strong><font size="5">What is "Solo Master"?</font></strong><br /><span>&#8203;When you use GIT simply to keep your code safe, to avoid going crazy after your laptop is broken/stolen, every changes are on the "master" branch only. Now you are in the &ldquo;solo master&rdquo; mode. In this mode, things are relatively easy, and there are mainly six possible scenarios:<br />&#8203;</span><br /><span>1. One&nbsp;</span><span>working</span><span>&nbsp;space, nothing goes wrong</span><br /><span>2.&nbsp;</span><span>One working space, mistake before "git add"</span><br /><span>3. One&nbsp;</span><span>working</span><span>&nbsp;</span><span>space</span><span>, mistake before "git commit"</span><br /><span>4. One&nbsp;</span><span>working</span><span>&nbsp;</span><span>space</span><span>, mistake before "git push"</span><br /><span>5.&nbsp;</span><span>One working space, mistake after "git push"<br />6. Multiple working spaces</span></div>   					 				</td>				<td class="wsite-multicol-col" style="width:33.333333333333%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/61juldqrr3l-ac-ul320-sr220-320_orig.jpg" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <div class="paragraph"><span>Note. There are many awesome resources out there talking about "what is Git", and "the basic concept in Git", I would refer to the official Git website on this "</span><a href="https://git-scm.com/book/en/v2/Getting-Started-Git-Basics" target="_blank">Getting Started -- Git Basic</a><span>"</span><br /><br /><span>Now we can start with some cool project! First, let's go to Github to create an empty project, then start to config it properly on your local laptop.</span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/published/screen-shot-2017-10-29-at-1-33-28-pm.png?1509309291" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="184312292614506658"><div><style type="text/css">	#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--light {  padding: 20px 0px;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--light .header .paragraph {  margin: 0;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--dark {  padding: 20px 0px;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--dark .header .paragraph {  margin: 0;}#element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-b83c47d0-de0c-4a30-b982-67aa6e90d8e0" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph"><span><strong><font size="5">Case 1. One working space, nothing goes wrong</font></strong><br />&#8203;This is the ideal and simplest situation, what you need to do is just add more files to one commit, commit the code, and then push to the remote master branch. Life is so easy under such situation.&nbsp;</span></div>  <div id="671741173218031343"><div><style type="text/css">	#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--light {  padding: 20px 0px;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--light .header .paragraph {  margin: 0;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--dark {  padding: 20px 0px;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--dark .header .paragraph {  margin: 0;}#element-08853adc-aa59-4c12-9388-60b533930b4c .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-08853adc-aa59-4c12-9388-60b533930b4c" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-10-41-09-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><strong><font size="5">Case</font></strong><span><strong><font size="5"> 2. One working space, mistake before "git add"</font></strong><br />&#8203;This always happen ... you started playing with your idea, and added a few draft code in the file, and quickly figured out this idea does not work, and now you want to get back the clean slate. How to do that? Fortunately, if you didn't run any "git add" on the new file, this is very easy.&nbsp;</span><br /><br /><span>For more details, please refer to</span> "<a href="https://git-scm.com/docs/git-checkout" target="_blank">Git checkout</a>".&nbsp;</div>  <div id="289893518453004579"><div><style type="text/css">	#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--light {  padding: 20px 0px;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--light .header .paragraph {  margin: 0;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--dark {  padding: 20px 0px;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--dark .header .paragraph {  margin: 0;}#element-9a8b6e12-b161-4da4-834f-476cb4c638c7 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-9a8b6e12-b161-4da4-834f-476cb4c638c7" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph"><strong><font size="5">Case 3. One working space, mistake before "git commit"</font></strong><br />&#8203;You thought the idea is going to work, added a few files, made some changes, did a few "git add", and finally, you figured out the result is not right. Now you want to get rid of the mess and back to the nice, right, old code.&nbsp;<br /><br /><span>For more details, please refer to</span> "<a href="https://git-scm.com/docs/git-reset" target="_blank">Git reset</a>".&nbsp;</div>  <div id="373537440608067683"><div><style type="text/css">	#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--light {  padding: 20px 0px;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--light .header .paragraph {  margin: 0;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--dark {  padding: 20px 0px;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--dark .header .paragraph {  margin: 0;}#element-32bda9dd-7ee2-4351-ae5e-206535a768e1 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-32bda9dd-7ee2-4351-ae5e-206535a768e1" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph"><font size="5"><strong>Case 4. One working space, mistake before "git push"</strong></font><br />You went even further this time, not only you did "git add", but also this modification took a few hours and you also did a few "git commit"! Ah, another huge mistake, what to do?!<br /><br /><span>For more details, please refer to</span> "<a href="https://git-scm.com/docs/git-reset" target="_blank">Git reset</a>".&nbsp;</div>  <div id="233718833962407198"><div><style type="text/css">	#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--light {  padding: 20px 0px;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--light .header .paragraph {  margin: 0;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--dark {  padding: 20px 0px;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--dark .header .paragraph {  margin: 0;}#element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-3b5a7e7a-1c1f-499d-9832-9c16426af9d6" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div id="300824472704234471"><div><style type="text/css">	#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--light {  padding: 20px 0px;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--light .header .paragraph {  margin: 0;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--dark {  padding: 20px 0px;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--dark .header .paragraph {  margin: 0;}#element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-4ac93aa2-3a05-4e37-9e53-cccfd6786c9e" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-04-01-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-05-59-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><font size="5"><strong>Case 5. One working space, mistake after "git push"</strong></font><br />You pushed the code to production, and other members found this is a big mistake/bug. Now you need to revert the code back to where it was.&nbsp;<br /><br />For more details, please refer to "<a href="https://git-scm.com/docs/git-revert" target="_blank">Git revert</a>".&nbsp;</div>  <div id="611295244554121546"><div><style type="text/css">	#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--light {  padding: 20px 0px;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--light .header .paragraph {  margin: 0;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--dark {  padding: 20px 0px;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--dark .header .paragraph {  margin: 0;}#element-ee783b95-1701-4068-ad54-a5cacc81f1a0 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-ee783b95-1701-4068-ad54-a5cacc81f1a0" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-17-02-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-17-12-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph"><font size="5"><strong>Case 6. Multiple working spaces</strong><br /></font>You have two working spaces, one is in your company laptop, one is in your company work station. You develop feature 2 in one working space, and feature 3 in another working space.&nbsp;</div>  <div id="380863783628023688"><div><style type="text/css">	#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--light {  padding: 20px 0px;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--light .header .paragraph {  margin: 0;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--dark {  padding: 20px 0px;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--dark .header .paragraph {  margin: 0;}#element-e82cf304-8da4-43ff-9f84-2787a50e2bd0 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-e82cf304-8da4-43ff-9f84-2787a50e2bd0" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph">Now you see the problem, and the solution is to use "git pull" first.&nbsp;<br />&#8203;"git pull" = "git fetch" + "git merge" or "git fetch" + "git rebase"<br />For the details, refer to "<a href="https://git-scm.com/docs/git-pull" target="_blank">Git pull</a>". Remember, n<span>ow the remote branch looks like following</span></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-43-21-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="795439223829713618"><div><style type="text/css">	#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--light {  padding: 20px 0px;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--light .header .paragraph {  margin: 0;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--dark {  padding: 20px 0px;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--dark .header .paragraph {  margin: 0;}#element-ab81919e-f7ca-44bb-a839-ef72d6290a82 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-ab81919e-f7ca-44bb-a839-ef72d6290a82" data-platform-element-id="270170748587580171-1.3.3" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-54-23-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2017-10-28-at-11-54-33-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">Now, as long as you develop each individual features in each working space, this process would have no problem. This is considered a better practice than working on the same feature in different working space. Because if the same file is modified in different spaces, the "merge" process will have many conflicts and resolving that would be a huge deal for "solo masters".&nbsp;<br /><br />Great, now after these simple case studies, you become the real "solo master" in Git. You will never lose any code (it will always be pushed to the cloud) or worry about code inconsistency in multiple working spaces (as long as "git pull" is used correctly).&nbsp;<br /><br />&#8203;Enjoy using Git!</div>]]></content:encoded></item><item><title><![CDATA[Thinking on "Executive Data Science" Specialization]]></title><link><![CDATA[http://www.magic-analytics.com/blog/thinking-on-executive-data-science-specialization]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/thinking-on-executive-data-science-specialization#comments]]></comments><pubDate>Sun, 08 Oct 2017 04:25:25 GMT</pubDate><category><![CDATA[Uncategorized]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/thinking-on-executive-data-science-specialization</guid><description><![CDATA[I love taking various online education resources to broaden my view and knowledge base. Recently, I finished the "Executive Data Science" specialization provided by Coursera, and found its quite helpful. Just write some thoughts on what I learned from this course.   sThese series courses does not provide technical knowledge for people to become data scientist, but offer the insights and toolkits to lead a data science project and manage a data science team. Although its discussion is mostly focu [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">I love taking various online education resources to broaden my view and knowledge base. Recently, I finished the "Executive Data Science" specialization provided by Coursera, and found its quite helpful. Just write some thoughts on what I learned from this course.</div>  <span class='imgPusher' style='float:left;height:0px'></span><span style='display: table;width:auto;position:relative;float:left;max-width:100%;;clear:left;margin-top:0px;*margin-top:0px'><a><img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/executive-data-science_orig.png" style="margin-top: 10px; margin-bottom: 10px; margin-left: 0px; margin-right: 10px; border-width:0; max-width:100%" alt="Picture" class="galleryImageBorder wsite-image" /></a><span style="display: table-caption; caption-side: bottom; font-size: 90%; margin-top: -10px; margin-bottom: 10px; text-align: center;" class="wsite-caption"></span></span> <div class="paragraph" style="display:block;">s<br /><br /><br /><span>These series courses does not provide technical knowledge for people to become data scientist, but offer the insights and toolkits to lead a data science project and manage a data science team. Although its discussion is mostly focusing on "statistical analytics insights - data scientist" work setting, I think quite a few concepts can still be transferable if working in a "machine learning product - data scientist" environment.</span><br /><br />The highlights in this specialization (for me) is following:<br />1. How to build a team: different focus and cooperation between "data engineer", "data scientist", and "business analyst". Although in reality, many times we play all three hats, it is nice to realize that intrinsically there are some difference so that to grow a team, we know what is the next stage hiring or knowledge sets required.&nbsp;<br />2. How to manage project: basically, using statistical sense to identify the top priority and move agilely along the right direction. I think most of the discussions make common sense in data science region, and it really helps to get a summarize view about how to prioritize data science focus, identify the right talent to do that, and continuously monitor/guide the project to produce end-result.<br /><br />Appreciate the faculties in Johns Hopkins to produce this great specialization. Happy learning!</div> <hr style="width:100%;clear:both;visibility:hidden;"></hr>  <div class="paragraph"></div>]]></content:encoded></item><item><title><![CDATA[Matplotlib Cheatsheet - Part 1]]></title><link><![CDATA[http://www.magic-analytics.com/blog/matplotlib-cheatsheet-part-1]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/matplotlib-cheatsheet-part-1#comments]]></comments><pubDate>Mon, 17 Apr 2017 05:58:18 GMT</pubDate><category><![CDATA[Matplotlib]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/matplotlib-cheatsheet-part-1</guid><description><![CDATA[There are many different visualization packages in Python, and matplotlib is arguably the most popular one. It has been developed for around 14 years, provides almost all functionalities available to visualize static graph. Recently, the 2.0 version upgrade makes its graph much nicer even using default style, so it definitely worth learning.&nbsp;Visualization in Matplotlib is not very easy, one need to know what each graph type is capable of, and their detailed parameters. So here, I wrote some [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">There are many different visualization packages in Python, and matplotlib is arguably the most popular one. It has been developed for around 14 years, provides almost all functionalities available to visualize static graph. Recently, the 2.0 version upgrade makes its graph much nicer even using default style, so it definitely worth learning.&nbsp;<br /><br />Visualization in Matplotlib is not very easy, one need to know what each graph type is capable of, and their detailed parameters. So here, I wrote some "sample code" as if a "cheatsheet": use (sometimes redundantly) more parameters to generate fairly complicated graph. In this case, whenever we encounter any customization request later, referring to these code could usually be helpful.<br /><br />This post covers following graph type: Pie, Bar, Hist, Boxplot, Violinplot. The details can be seen in following three links:&nbsp;<br /><a href="https://htmlpreview.github.io/?https://github.com/PanWu/cheatsheet-matplotlib/blob/master/pie-bar-plot.html" target="_blank">Pie-Bar</a>, <a href="https://htmlpreview.github.io/?https://github.com/PanWu/cheatsheet-matplotlib/blob/master/hist-plot.html" target="_blank">Hist</a>, <a href="https://htmlpreview.github.io/?https://github.com/PanWu/cheatsheet-matplotlib/blob/master/box-violin-plot.html" target="_blank">Box-Violin</a></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_11_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_12_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_13_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[RGB Representation for classes]]></title><link><![CDATA[http://www.magic-analytics.com/blog/rgb-representation-for-classes]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/rgb-representation-for-classes#comments]]></comments><pubDate>Sun, 27 Nov 2016 07:57:30 GMT</pubDate><category><![CDATA[Matplotlib]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/rgb-representation-for-classes</guid><description><![CDATA[Initially, in the plot_decision_boundary&nbsp;code, I used hard-code color schema to represent each class. If the input class # is higher than that, an error will be presented. This may not be the best approach. Then I start to think about: how to define class RGB representation in this specific use case? Basically, here is a few fact/requirement:Fact:&nbsp;F-1. any data point has a probability associated with different class, they sum to 1.&nbsp;Requirement:R-1. If one point is 100% in class A, [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Initially, in the plot_decision_boundary&nbsp;<span>code</span>, I used hard-code color schema to represent each class. If the input class # is higher than that, an error will be presented. This may not be the best approach. Then I start to think about: how to define class RGB representation in this specific use case? Basically, here is a few fact/requirement:<br />Fact:&nbsp;<br />F-1. any data point has a probability associated with different class, they sum to 1.&nbsp;<br /><br />Requirement:<br />R-1. If one point is 100% in class A, it should have a unique color, and cannot be constructed as a hybrid composition by other classes.&nbsp;<br />R-2. Each color represents a unique combination of different classes composition.&nbsp;<br />&nbsp; &nbsp; &nbsp;<br />For R-2, after some thinking, I found it is impossible to get such no-duplication satisfied. This is because as long as the class # is larger than 4 (3 + 1), due to the dimensionality difference, there must be a duplication happens. So ignore this requirement.&nbsp;<br /><br />For condition R-1, it could be satisfied as long as the RGB value for all classes form a strict convex object within RGB 3D space. A simple example is: on a RG 2D space, if we use (0,0), (1,0), (0,1), (1,1) as class color definition, no class can be represented by a composition of other classes (based on coefficient sum to 1). However, if we add a new class like (0.5, 1.0), it can be written as:<br />&nbsp;&nbsp; &nbsp;(0.5, 1.0) = 50% * (1, 1) + 50% * (0, 1)<br /><br />This is because the extra point is not making the class color geometry strict convex any more.<br /><br />A easier solution is to define a sphere within RGB 3D box, and taking the color representation over the sphere as each class color. In this case, R-1. should be satisfied.&nbsp;<br /><br />However, in practice, I found if using just the sphere, the contrast between classes will be smaller than ignore R-1. Here is the comparison between 20 colors and 100 colors between a sphere surface representation vs. RGB 3D surface representation. Currently, I set it as the default in plot_decision_boundary function.&nbsp;</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_9.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_10.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item><item><title><![CDATA[Visualize decision boundary in Python]]></title><link><![CDATA[http://www.magic-analytics.com/blog/visualize-decision-boundary-in-python]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/visualize-decision-boundary-in-python#comments]]></comments><pubDate>Fri, 25 Nov 2016 02:04:23 GMT</pubDate><category><![CDATA[Machine Learning]]></category><category><![CDATA[Matplotlib]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/visualize-decision-boundary-in-python</guid><description><![CDATA[One great way to understanding how classifier works is through visualizing its decision boundary. In scikit-learn, there are several nice posts about visualizing decision boundary (plot_iris, plot_voting_decision_region); however, it usually require quite a few lines of code, and not directly usable. So I write the following function, hope it could serve as a general way to visualize 2D decision boundary for any classification models. (see&nbsp;Github, the notebook is Here)(Note. a few updates a [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">One great way to understanding how classifier works is through visualizing its decision boundary. In scikit-learn, there are several nice posts about visualizing decision boundary (<a target="_blank" href="http://scikit-learn.org/stable/auto_examples/svm/plot_iris.html">plot_iris</a>, <a target="_blank" href="http://scikit-learn.org/stable/auto_examples/ensemble/plot_voting_decision_regions.html">plot_voting_decision_region</a>); however, it usually require quite a few lines of code, and not directly usable. So I write the following function, hope it could serve as a general way to visualize 2D decision boundary for any classification models. (see&nbsp;<a target="_blank" href="https://github.com/PanWu/pylib/blob/master/pylib/plot.py">Github</a>, the notebook is <a href="https://github.com/PanWu/pylib/blob/master/example/01.plot_decision_boundary.ipynb" target="_blank">Here</a>)<br /><br />(Note. a few updates after my first publish, in current version:<br />1. the API is much simpler<br />2. add dimension reduction (PCA) to handle higher dimension cases<br />3. wrap the function into the package (pylib)<br />)<br /><br />The usage of this function is quite simple, here it is:</div>  <div id="335508540881702333"><div><style type="text/css">	#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--light {  padding: 20px 0px;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--light .header .paragraph {  margin: 0;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--dark {  padding: 20px 0px;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--dark .header .paragraph {  margin: 0;}#element-24dd3b18-248c-4aba-967d-43a2424e7750 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-24dd3b18-248c-4aba-967d-43a2424e7750" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div id="476546221975428965"><div><style type="text/css">	#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--light {  padding: 20px 0px;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--light .header .paragraph {  margin: 0;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--dark {  padding: 20px 0px;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--dark .header .paragraph {  margin: 0;}#element-20ca6944-7611-46aa-b422-7368c210f464 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-20ca6944-7611-46aa-b422-7368c210f464" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_3.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="687889842659564693"><div><style type="text/css">	#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--light {  padding: 20px 0px;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--light .header .paragraph {  margin: 0;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--dark {  padding: 20px 0px;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--dark .header .paragraph {  margin: 0;}#element-0a1b1210-0abf-4278-9b36-87b2776e99f4 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-0a1b1210-0abf-4278-9b36-87b2776e99f4" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_4.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="780539723262695209"><div><style type="text/css">	#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--light {  padding: 20px 0px;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--light .header .paragraph {  margin: 0;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--dark {  padding: 20px 0px;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--dark .header .paragraph {  margin: 0;}#element-8b450f9e-2665-4691-bff9-db0e28cd5de1 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-8b450f9e-2665-4691-bff9-db0e28cd5de1" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_5.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="718739191178107761"><div><style type="text/css">	#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--light {  padding: 20px 0px;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--light .header .paragraph {  margin: 0;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--dark {  padding: 20px 0px;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--dark .header .paragraph {  margin: 0;}#element-a8d2b647-3fd1-4f42-a32e-238597e6e522 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-a8d2b647-3fd1-4f42-a32e-238597e6e522" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/download_6.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">In the random forest case, we see the decision boundary is not very continuous as the previous two models. This is because the decision boundary is calculated based on model prediction result: if the predict class changes on this grid, this grid will be identified as on decision boundary. However, if the model has strong&nbsp;<span style="color:rgb(84, 84, 84)">volatile behavior in some space, it will be displayed as if decision boundary here.&nbsp;</span><br /><br />Happy Thanksgiving!&nbsp;</div>]]></content:encoded></item><item><title><![CDATA[Python vs. R in data science]]></title><link><![CDATA[http://www.magic-analytics.com/blog/python-vs-r-in-data-science]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/python-vs-r-in-data-science#comments]]></comments><pubDate>Sat, 19 Nov 2016 07:50:55 GMT</pubDate><category><![CDATA[Python]]></category><category><![CDATA[R]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/python-vs-r-in-data-science</guid><description><![CDATA[One question constantly persists: Python vs. R, which one is better for data scientist. I read many blogs and forum discussion, and although some answers are great, quite a few are subjective.&nbsp;Here I found one great, detailed comparison, and I totally agree with the author's conclusion, the original link is here:&nbsp;https://www.dataquest.io/blog/python-vs-r/&nbsp;Convert this blog's summary into a table for easy reference:&nbsp;   	 		 			 				 					 						  R:more functional&nbsp;more da [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">One question constantly persists: Python vs. R, which one is better for data scientist. I read many blogs and forum discussion, and although some answers are great, quite a few are subjective.&nbsp;<br /><br />Here I found one great, detailed comparison, and I totally agree with the author's conclusion, the original link is here:&nbsp;<br /><a href="https://www.dataquest.io/blog/python-vs-r/" target="_blank">https://www.dataquest.io/blog/python-vs-r/&nbsp;</a><br /><br />Convert this blog's summary into a table for easy reference:&nbsp;</div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div class="paragraph">R:<ul><li>more functional&nbsp;</li><li>more data analysis built-ins</li><li>larger ecosystem of smaller packages&nbsp;</li><li>more statistical support in general</li><li>...... R is build for statistician! ...... &#8203;</li></ul></div>   					 				</td>				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div class="paragraph">Python:<ul><li>&#8203;more objective orientated</li><li>relies on packages (pandas, scikit-learn)</li><li>has "main" packages for data analysis</li><li>..... statsmodels ? not quite &nbsp;....&nbsp;</li><li>non-statistical tasks is quite good</li></ul></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>]]></content:encoded></item><item><title><![CDATA[Pandas: group-by and index]]></title><link><![CDATA[http://www.magic-analytics.com/blog/pandas-group-by-and-index]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/pandas-group-by-and-index#comments]]></comments><pubDate>Sat, 05 Nov 2016 01:31:56 GMT</pubDate><category><![CDATA[Pandas]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/pandas-group-by-and-index</guid><description><![CDATA[Group-by in Pandas is widely used, and since Pandas is heavily using Index, it may be not very convenient to directly "chain" the group-by statement with downstream analytics statement (especially if one need to aggregate multiple statistics for the same column. Here is a demo  	#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light {  padding: 20px 0px;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1 [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">Group-by in Pandas is widely used, and since Pandas is heavily using Index, it may be not very convenient to directly "chain" the group-by statement with downstream analytics statement (especially if one need to aggregate multiple statistics for the same column. Here is a demo</div>  <div id="720532350988526881"><div><style type="text/css">	#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light {  padding: 20px 0px;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light .header .paragraph {  margin: 0;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--dark {  padding: 20px 0px;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--dark .header .paragraph {  margin: 0;}#element-418fbc4d-9fcc-4ed7-859d-787fdde154ff .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-418fbc4d-9fcc-4ed7-859d-787fdde154ff" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:49.999999999999%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-11-04-at-6-38-36-pm.png?244" alt="Picture" style="width:244;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>				<td class="wsite-multicol-col" style="width:49.999999999999%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0px;margin-right:0px;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-11-04-at-6-38-47-pm.png?318" alt="Picture" style="width:318;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <div id="949451399284815306"><div><style type="text/css">	#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--light {  padding: 20px 0px;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--light .header .paragraph {  margin: 0;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--dark {  padding: 20px 0px;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--dark .header .paragraph {  margin: 0;}#element-4be4dacd-90f1-420d-8de6-c4a9c25067de .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-4be4dacd-90f1-420d-8de6-c4a9c25067de" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph">To avoid this "friction", a nicer approach (for people not familiar using index, including me) is following approach.</div>  <div id="673782322343173003"><div><style type="text/css">	#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--light {  padding: 20px 0px;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--light .header .paragraph {  margin: 0;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--dark {  padding: 20px 0px;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--dark .header .paragraph {  margin: 0;}#element-f391d4d4-c621-47a5-a9f0-fef62eaa7856 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-f391d4d4-c621-47a5-a9f0-fef62eaa7856" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-multicol"><div class="wsite-multicol-table-wrap" style="margin:0 -15px;"> 	<table class="wsite-multicol-table"> 		<tbody class="wsite-multicol-tbody"> 			<tr class="wsite-multicol-tr"> 				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-11-06-at-7-05-29-am.png?272" alt="Picture" style="width:272;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>				<td class="wsite-multicol-col" style="width:50%; padding:0 15px;"> 					 						  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-11-06-at-7-05-36-am_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>   					 				</td>			</tr> 		</tbody> 	</table> </div></div></div>  <div class="paragraph">This would make the group-by statement in Pandas index-free (good for index-frustrated users :) ).<br /><br />The original discussion was on Github:&nbsp;<a href="https://github.com/pandas-dev/pandas/issues/14581" target="_blank">https://github.com/pandas-dev/pandas/issues/14581</a></div>]]></content:encoded></item><item><title><![CDATA[PySpark vs. Pandas (Part 5: SQL-windows function)]]></title><link><![CDATA[http://www.magic-analytics.com/blog/pyspark-vs-pandas-part-5-sql-windows-function]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/pyspark-vs-pandas-part-5-sql-windows-function#comments]]></comments><pubDate>Mon, 31 Oct 2016 15:36:44 GMT</pubDate><category><![CDATA[Pandas]]></category><category><![CDATA[Spark]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/pyspark-vs-pandas-part-5-sql-windows-function</guid><description><![CDATA[In SQL, by defining a specific "window", one can perform "calculation across a set of table rows that are somehow related to the current row" (from PostgreSQL). This greatly extend SQL's analytics power.The implementation in PySpark is quite close (syntactically) to SQL, one have to define a "window" literally; while for Pandas, although it also has a "window" function, I found it is more like a rolling window, rather the SQL's window functionality. (correct me if I am wrong).&nbsp;My preferred  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph"><font color="#626262">In SQL, by defining a specific "window", one can perform "calculation across a set of table rows that are somehow related to the current row" (from <a target="_blank" href="https://www.postgresql.org/docs/9.1/static/tutorial-window.html">PostgreSQL</a>). This greatly extend SQL's analytics power.<br /><br />The implementation in PySpark is quite close (syntactically) to SQL, one have to define a "window" literally; while for Pandas, although it also has a "window" function, I found it is more like a rolling window, rather the SQL's window functionality. (correct me if I am wrong).&nbsp;<br /><br />My preferred way to&nbsp;replicate&nbsp;windows function in Pandas and PySpark is below:</font></div>  <div id="168822937906625181"><div><style type="text/css">	#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--light {  padding: 20px 0px;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--light .header .paragraph {  margin: 0;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--dark {  padding: 20px 0px;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--dark .header .paragraph {  margin: 0;}#element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-b3d8bca0-a6b1-4fa8-b106-157eb1b166bd" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-10-31-at-11-44-53-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div id="540725474720405926"><div><style type="text/css">	#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--light {  padding: 20px 0px;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--light .header .paragraph {  margin: 0;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--dark {  padding: 20px 0px;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--dark .header .paragraph {  margin: 0;}#element-81d10c7e-8a53-467a-9fcb-1539d356be49 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-81d10c7e-8a53-467a-9fcb-1539d356be49" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-10-31-at-11-48-16-pm.png?383" alt="Picture" style="width:383;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">From this comparison, looks like PySpark is more SQL-straightforward, with a nice syntax to do that. However, actually Pandas is more versatile and many different functionality could be defined from the "assign" keyword. Good or bad? I think it depends.&nbsp;</div>]]></content:encoded></item><item><title><![CDATA[Plotly: subplots in figure (Part 2)]]></title><link><![CDATA[http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-2]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-2#comments]]></comments><pubDate>Mon, 31 Oct 2016 05:29:35 GMT</pubDate><category><![CDATA[Plotly]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-2</guid><description><![CDATA[The caveat in Part 1 is about Pie chart: if one trying to replace any go.Bar or go.Histogram with go.Pie chart, there will be an error showing (plotly version 1.12.9)&nbsp;  	#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light {  padding: 20px 0px;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">The caveat in <a href="http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-1">Part 1</a> is about Pie chart: if one trying to replace any go.Bar or go.Histogram with go.Pie chart, there will be an error showing (plotly version 1.12.9)&nbsp;</div>  <div id="972752077775033483"><div><style type="text/css">	#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light {  padding: 20px 0px;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light .header .paragraph {  margin: 0;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--dark {  padding: 20px 0px;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--dark .header .paragraph {  margin: 0;}#element-531e0bd6-d6f5-4996-84be-edc946297a5c .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-531e0bd6-d6f5-4996-84be-edc946297a5c" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-10-30-at-10-40-02-pm_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">The reason for this is because the "tools.make_subplots" function creates a set of subplots based on different xaxis and yaxis, while go.Pie does not require (and it does not have) an axis property.&nbsp;<br /><br />The way to overcome such challenge is to build up the graph from scratch, using "domain" and "anchor".<br /><br />To explain the concept, take a look at the "layout" in<span>&nbsp;</span><a href="http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-1">Part 1</a>'s example. Each layout axis (x and y) is attached with a specific domain on this figure, with its axis "anchored" with a specific data. subplot-1 is on upper left, so its xaxis domain is [0, 0.45] (left side), and yaxis domain is [0.625, 1] (upper side).</div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/screen-shot-2016-10-30-at-10-40-02-pm_1_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">For Pie plot, since it cannot have axis, the make_subplots approach fake, but following approach still works</div>  <div id="292881198520425960"><div><style type="text/css">	#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--light {  padding: 20px 0px;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--light .header .paragraph {  margin: 0;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--dark {  padding: 20px 0px;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--dark .header .paragraph {  margin: 0;}#element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-ac0c4ce7-ccb3-430a-a027-f3339e0cd228" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/newplot-30_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>  <div class="paragraph">I have to say, I hate to use the Annotation as a way to make the subplot's title ... however, I currently didn't find any other way to directly assign subplot title. If you got any better approach to simplify the code in general, feel free to comment on this blog.&nbsp;</div>]]></content:encoded></item><item><title><![CDATA[Plotly: subplots in figure (Part 1)]]></title><link><![CDATA[http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-1]]></link><comments><![CDATA[http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-1#comments]]></comments><pubDate>Mon, 31 Oct 2016 00:39:11 GMT</pubDate><category><![CDATA[Plotly]]></category><category><![CDATA[Python]]></category><guid isPermaLink="false">http://www.magic-analytics.com/blog/plotly-subplots-in-figure-part-1</guid><description><![CDATA[In Matplotlib, subplot can be easily pulled out as following:  	#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light {  padding: 20px 0px;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light .header .paragraph {  [...] ]]></description><content:encoded><![CDATA[<div class="paragraph">In Matplotlib, subplot can be easily pulled out as following:</div>  <div id="611553200386138284"><div><style type="text/css">	#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light {  padding: 20px 0px;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light .header .paragraph {  margin: 0;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--dark {  padding: 20px 0px;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--dark .header .paragraph {  margin: 0;}#element-88667db2-e064-4ea8-a827-df893fa62db1 .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-88667db2-e064-4ea8-a827-df893fa62db1" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div class="paragraph">However, matplotlib is not quite smart to handle the axis ticks rotation (sometimes they collapse together and hard to visualize), and this could be troublesome for some automatic visualization process.&nbsp;In general, I found plotly offer a better automated layout.<br /><br />The way subplots in plotly and matplotlib are conceptually different on:<br />1. (matplotlib) figure --- axes ---&nbsp;<span>artist</span>, so that one figure can contain multiple axes, and each axes has their own set of artist. For example, legend is an artist, and each axes could have its own legend<br />2. (plotly) the main component in a figure is "data" and "layout", the way subplot works is to create multiple data, put into different axis. This is still one big figure. each subplot is just different axis(x,y) located on different locations in this big Figure.&nbsp;<br /><br />Here is a few action<br /></div>  <div id="474503878264041260"><div><style type="text/css">	#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--light {  padding: 20px 0px;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--light .header .paragraph {  margin: 0;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--dark {  padding: 20px 0px;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--dark .header .paragraph {  margin: 0;}#element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-0ecdf7cc-8727-408a-b088-b6b5545a6f3c" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div id="541585733888654219"><div><style type="text/css">	#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--light {  padding: 20px 0px;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--light .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #C9CDCF;  border-right: 1px solid #C9CDCF;  border-top: 1px solid #C9CDCF;  background-color: #F8F8F8;  color: #363B3E;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--light .header .paragraph {  margin: 0;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--light .body-code {  margin: 0;  border: 1px solid #C9CDCF;  background-color: #FFFFFF;  color: #666C70;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--dark {  padding: 20px 0px;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--dark .ace-tomorrow-night-eighties {  background-color: #363B3E;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--dark .header {  padding: 10px 20px;  font-weight: bold;  border-left: 1px solid #E0E1E2;  border-right: 1px solid #E0E1E2;  border-top: 1px solid #E0E1E2;  background-color: #666C70;  color: #FFFFFF;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--dark .header .paragraph {  margin: 0;}#element-cc2934c9-72ec-4cc4-8238-71730427777a .code-editor--dark .body-code {  margin: 0;  border: 1px solid #E0E1E2;  background-color: #363B3E;  color: #F8F8F8;}</style><div id="element-cc2934c9-72ec-4cc4-8238-71730427777a" data-platform-element-id="270170748587580171-1.3.2" class="platform-element-contents">	<div class="code-editor--light">    <div class="header">        <div class="paragraph"></div>    </div>    <div class="body-code">        <pre class="editor"></pre>    </div></div></div><div style="clear:both;"></div></div></div>  <div><div class="wsite-image wsite-image-border-none " style="padding-top:10px;padding-bottom:10px;margin-left:0;margin-right:0;text-align:center"> <a> <img src="http://www.magic-analytics.com/uploads/7/3/3/3/73333423/newplot-29_orig.png" alt="Picture" style="width:auto;max-width:100%" /> </a> <div style="display:block;font-size:90%"></div> </div></div>]]></content:encoded></item></channel></rss>