<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/introducing-cricpya-python-package-to-analyze-performances-of-cricketers/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/"> R – Giga thoughts …</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><em>Full many a gem of purest ray serene,<br>
The dark unfathomed caves of ocean bear;<br>
Full many a flower is born to blush unseen,<br>
And waste its sweetness on the desert air.</em></p>
<pre><code>            Thomas Gray, An Elegy Written In A Country Churchyard
            </code></pre>
<div>
<h1>Introduction</h1>
<p>It is finally here! <strong>cricpy</strong>, the python avatar , of my R package <strong>cricketr</strong> is now ready to rock-n-roll! My R package cricketr had its genesis about 3 and some years ago and went through a couple of enhancements. During this time I have always thought about creating an equivalent python package like cricketr. Now I have finally done it.</p>
<p>So here it is. My python package <strong>‘cricpy!!!’</strong></p>
<p>This package uses the statistics info available in <a rel="nofollow" href="http://stats.espncricinfo.com/ci/engine/stats/index.html" target="_blank">ESPN Cricinfo Statsguru</a>. The current version of this package supports only Test cricket</p>
<p>You should be able to install the package using <strong>pip install cricpy</strong> and use the many functions available in the package. Please mindful of the <a rel="nofollow" href="http://www.espncricinfo.com/ci/content/site/company/terms_use.html" target="_blank">ESPN Cricinfo Terms of Use</a></p>
<p>This post is also hosted on Rpubs at <a rel="nofollow" href="http://rpubs.com/tvganesh/433972" target="_blank">Introducing cricpy</a>. You can also download the pdf version of this post at <a rel="nofollow" href="https://drive.google.com/file/d/1Xn3YUnC8TxaGPxtr5nfh28hQkRobseKr/view?usp=sharing" target="_blank">cricpy.pdf</a></p>
<p>Do check out my post on R package cricketr at <a rel="nofollow" href="https://gigadom.in/2016/05/14/re-introducing-cricketr-an-r-package-to-analyze-performances-of-cricketers/" target="_blank">Re-introducing cricketr! : An R package to analyze performances of cricketers</a></p>
<p>If you are passionate about cricket, and love analyzing cricket performances, then check out my 2 racy books on cricket! In my books, I perform detailed yet compact analysis of performances of both batsmen, bowlers besides evaluating team &amp; match performances in Tests , ODIs, T20s &amp; IPL. You can buy my books on cricket from Amazon at $12.99 for the paperback and $4.99/$6.99 respectively for the kindle versions. The books can be accessed at <a rel="nofollow" href="https://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Cricket+analytics+with+cricketr%3A+Third+edition&rh=i%3Aaps%2Ck%3ACricket+analytics+with+cricketr%3A+Third+edition" target="_blank">Cricket analytics with cricketr</a>  and <a rel="nofollow" href="https://www.amazon.com/dp/1973561719" target="_blank">Beaten by sheer pace-Cricket analytics with yorkr </a> A must read for any cricket lover! Check it out!!</p>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2014/12/12.png" data-orig-size="1126,662" data-medium-file="https://gigadom.files.wordpress.com/2014/12/12.png?w=300" data-attachment-id="6603" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2014/12/12.png?w=450&h=397&fit=676%2C397" data-permalink="https://gigadom.in/2014/12/12/informed-choices-through-machine-learning-analyzing-kohli-tendulkar-and-dravid/1-55/" data-large-file="https://gigadom.files.wordpress.com/2014/12/12.png?w=676" alt="1" data-image-title="1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6603" data-recalc-dims="1"></p>
<p> </p>
<p>This package uses the statistics info available in <a rel="nofollow" href="http://stats.espncricinfo.com/ci/engine/stats/index.html" target="_blank">ESPN Cricinfo Statsguru</a>. T</p>
</div>
<div>
<h1>The <strong>cricpy</strong> package</h1>
<p>The cricpy package has several functions that perform several different analyses on both batsman and bowlers. The package has functions that plot percentage frequency runs or wickets, runs likelihood for a batsman, relative run/strike rates of batsman and relative performance/economy rate for bowlers are available.</p>
<p>Other interesting functions include batting performance moving average, forecasting, performance of a player against different oppositions, contribution to wins and losses etc.</p>
<p>The data for a particular player can be obtained with the getPlayerData() function. To do this you will need to go to <a rel="nofollow" href="http://www.espncricinfo.com/ci/content/player/index.html" target="_blank">ESPN CricInfo Player</a> and type in the name of the player for e.g Rahul Dravid, Virat Kohli, Alastair Cook etc. This will bring up a page which have the profile number for the player e.g. for Rahul Dravid this would be <a rel="nofollow" href="http://www.espncricinfo.com/india/content/player/28114.html" target="_blank">http://www.espncricinfo.com/india/content/player/28114.html</a>. Hence, Dravid’s profile is 28114. This can be used to get the data for Rahul Dravid as shown below</p>
<p>The cricpy package is almost a clone of my R package cricketr. The signature of all the python functions are identical with that of its R avatar namely  ‘cricketr’, with only the necessary variations between Python and R. It may be useful to look at my post <a rel="nofollow" href="https://gigadom.in/2017/05/22/r-vs-python-different-similarities-and-similar-differences/" target="_blank">R vs Python: Different similarities and similar differences</a>. In fact if you are familiar with one of the languages you can look up the package in the other and you will notice the parallel constructs. You can fork/clone the package at Github <a rel="nofollow" href="https://github.com/tvganesh/cricpy" target="_blank">cricpy</a></p>
<p>The following 2 examples show the similarity between cricketr and cricpy packages</p>
<div>
<h2>1a.Importing cricketr – R</h2>
<p>Importing cricketr in R</p>
<pre><code><span>#install.packages(&quot;cricketr&quot;)</span>
<span>library</span>(cricketr)</code></pre>
</div>
<div>
<h2>2a. Importing cricpy – Python</h2>
<pre><code><span># Install the package</span>
<span># Do a pip install cricpy</span>
<span># Import cricpy</span>
<span>import</span> cricpy
<span># You could either do</span>
<span>#1. </span>
<span>import</span> cricpy.analytics <span>as</span> ca 
<span>#ca.batsman4s(&quot;../dravid.csv&quot;,&quot;Rahul Dravid&quot;)</span>
<span># Or</span>
<span>#2.</span></code></pre>
<pre><code><span>from</span> cricpy.analytics <span>import</span> *
<span>#batsman4s(&quot;../dravid.csv&quot;,&quot;Rahul Dravid&quot;)
</span></code></pre>
</div>
<div>
<p>I would recommend using option 1 namely ca.batsman4s() as I may add an advanced analytics module in the future to cricpy.</p>
<h2>2 Invoking functions</h2>
<p>You can seen how the 2 calls are identical for both the R package cricketr and the Python package cricpy</p>
</div>
<div>
<h2>2a. Invoking functions with R package ‘<strong>cricketr’</strong></h2>
<pre><code><span>library</span>(cricketr)
batsman4s(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-3-1.png" data-orig-size="1344,960" data-medium-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-3-1.png?w=300" data-attachment-id="6953" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-3-1.png?w=450&h=483&fit=676%2C483" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/unnamed-chunk-3-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-3-1.png?w=450&amp;h=483&amp;fit=676%2C483" alt="" data-image-title="unnamed-chunk-3-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6953" data-recalc-dims="1"></p>
</div>
<div>
<h2>2b. Invoking functions with Python package ‘<strong>cricpy’</strong></h2>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca 
ca.batsman4s(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-4-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-4-1.png?w=300" data-attachment-id="6954" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-4-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/unnamed-chunk-4-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/unnamed-chunk-4-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="unnamed-chunk-4-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6954" data-recalc-dims="1"></p>
<p> </p>
<div>
<h1>3a. Getting help from cricketr – R</h1>
<pre><code><span>#help(&quot;batsman4s&quot;)</span></code></pre>
</div>
<div>
<h1>3b. Getting help from cricpy – Python</h1>
<pre><code>help(ca.batsman4s)</code></pre>
</div>
</div>
<div>
<p>The details below will introduce the different functions that are available in cricpy.</p>
<h2>3. Get the player data for a player using the function getPlayerData()</h2>
<p><strong>Important Note</strong> This needs to be done only once for a player. This function stores the player’s data in the specified CSV file (for e.g. dravid.csv as above) which can then be reused for all other functions). Once we have the data for the players many analyses can be done. This post will use the stored CSV file obtained with a prior getPlayerData for all subsequent analyses</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>#dravid =ca.getPlayerData(28114,dir=&quot;..&quot;,file=&quot;dravid.csv&quot;,type=&quot;batting&quot;,homeOrAway=[1,2], result=[1,2,4])</span>
<span>#acook =ca.getPlayerData(11728,dir=&quot;..&quot;,file=&quot;acook.csv&quot;,type=&quot;batting&quot;,homeOrAway=[1,2], result=[1,2,4])</span></code></pre>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>#lara =ca.getPlayerData(52337,dir=&quot;..&quot;,file=&quot;lara.csv&quot;,type=&quot;batting&quot;,homeOrAway=[1,2], result=[1,2,4])253802</span>
<span>#kohli =ca.getPlayerData(253802,dir=&quot;..&quot;,file=&quot;kohli.csv&quot;,type=&quot;batting&quot;,homeOrAway=[1,2], result=[1,2,4])</span></code></pre>
</div>
<div>
<h2>4 Rahul Dravid’s performance – Basic Analyses</h2>
<p>The 3 plots below provide the following for Rahul Dravid</p>
<ol>
<li>Frequency percentage of runs in each run range over the whole career</li>
<li>Mean Strike Rate for runs scored in the given range</li>
<li>A histogram of runs frequency percentages in runs ranges</li>
</ol>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>import</span> matplotlib.pyplot <span>as</span> plt
ca.batsmanRunsFreqPerf(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/basic-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/basic-1.png?w=300" data-attachment-id="6957" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/basic-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/basic-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/basic-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="basic-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6957" data-recalc-dims="1"></p>
<pre><code>ca.batsmanMeanStrikeRate(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/basic-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/basic-2.png?w=300" data-attachment-id="6958" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/basic-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/basic-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/basic-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="basic-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6958" data-recalc-dims="1"></p>
<pre><code>ca.batsmanRunsRanges(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>) </code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/basic-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/basic-3.png?w=300" data-attachment-id="6959" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/basic-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/basic-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/basic-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="basic-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6959" data-recalc-dims="1"></p>
</div>
<div>
<h2>5. More analyses</h2>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsman4s(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-1.png?w=300" data-attachment-id="6961" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-4s6sout-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-4s6sout-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6961" data-recalc-dims="1"></p>
<pre><code>ca.batsman6s(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>) </code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-2.png?w=300" data-attachment-id="6962" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-4s6sout-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-4s6sout-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6962" data-recalc-dims="1"></p>
<pre><code>ca.batsmanDismissals(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-3.png?w=300" data-attachment-id="6963" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-4s6sout-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-4s6sout-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-4s6sout-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6963" data-recalc-dims="1"></p>
</div>
<div>
<h2>6. 3D scatter plot and prediction plane</h2>
<p>The plots below show the 3D scatter plot of Dravid Runs versus Balls Faced and Minutes at crease. A linear regression plane is then fitted between Runs and Balls Faced + Minutes at crease</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.battingPerf3d(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-3d-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-3d-1.png?w=300" data-attachment-id="6964" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-3d-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-3d-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-3d-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-3d-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6964" data-recalc-dims="1"></p>
</div>
<h2>7. Average runs at different venues</h2>
<p>The plot below gives the average runs scored by Dravid at different grounds. The plot also the number of innings at each ground as a label at x-axis. It can be seen Dravid did great in Rawalpindi, Leeds, Georgetown overseas and , Mohali and Bangalore at home</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanAvgRunsGround(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p> </p>
<div>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-runsgrd-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-runsgrd-1.png?w=300" data-attachment-id="6966" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-runsgrd-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-runsgrd-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-runsgrd-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-runsgrd,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6966" data-recalc-dims="1"></h2>
<h2>8. Average runs against different opposing teams</h2>
<p>This plot computes the average runs scored by Dravid against different countries. Dravid has an average of 50+ in England, New Zealand, West Indies and Zimbabwe.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanAvgRunsOpposition(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
</div>
</div>
<div><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-avgopn-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-avgopn-1.png?w=300" data-attachment-id="6968" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-avgopn-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-avgopn-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-avgopn-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-avgopn,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6968" data-recalc-dims="1"></div>
<div>
<h2>9 . Highest Runs Likelihood</h2>
<p>The plot below shows the Runs Likelihood for a batsman. For this the performance of Sachin is plotted as a 3D scatter plot with Runs versus Balls Faced + Minutes at crease. K-Means. The centroids of 3 clusters are computed and plotted. In this plot Dravid’s  highest tendencies are computed and plotted using K-Means</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanRunsLikelihood(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
</div>
<h1><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dravid-kmeans-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dravid-kmeans-1.png?w=300" data-attachment-id="6969" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dravid-kmeans-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dravid-kmeans-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dravid-kmeans-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dravid-kmeans,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6969" data-recalc-dims="1"></h1>
<h2>10. A look at the Top 4 batsman – Rahul Dravid, Alastair Cook, Brian Lara and Virat Kohli</h2>
<p>The following batsmen have been very prolific in test cricket and will be used for teh analyses</p>
<ol>
<li>Rahul Dravid :<strong>Average:52.31,100’s – 36, 50’s – 63</strong></li>
<li>Alastair Cook : <strong>Average: 45.35, 100’s – 33, 50’s – 57</strong></li>
<li>Brian Lara : <strong>Average: 52.88, 100’s – 34 , 50’s – 48</strong></li>
<li>Virat Kohli: <strong>Average: 54.57 ,100’s – 24 , 50’s – 19</strong></li>
</ol>
<p>The following plots take a closer at their performances. The box plots show the median the 1st and 3rd quartile of the runs</p>
<div>
<h2>11. Box Histogram Plot</h2>
<p>This plot shows a combined boxplot of the Runs ranges and a histogram of the Runs Frequency</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanPerfBoxHist(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-1.png?w=300" data-attachment-id="6971" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dakl-boxhist-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dakl-boxhist-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6971" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfBoxHist(<span>&quot;../acook.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<div>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-2.png?w=300" data-attachment-id="6972" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dakl-boxhist-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dakl-boxhist-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6972" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfBoxHist(<span>&quot;../lara.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><br>
<img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-3.png?w=300" data-attachment-id="6973" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dakl-boxhist-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dakl-boxhist-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6973" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfBoxHist(<span>&quot;../kohli.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img><br>
<img data-orig-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-4.png?w=300" data-attachment-id="6974" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/dakl-boxhist-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/dakl-boxhist-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="dakl-boxhist-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6974" data-recalc-dims="1"></p>
</div>
<div>
<h2>12. Contribution to won and lost matches</h2>
<p>The plot below shows the contribution of Dravid, Cook, Lara and Kohli in matches won and lost. It can be seen that in matches where India has won Dravid and Kohli have scored more and must have been instrumental in the win</p>
<p>For the 2 functions below you will have to use the getPlayerDataSp() function as shown below. I have commented this as I already have these files</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>#dravidsp = ca.getPlayerDataSp(28114,tdir=&quot;.&quot;,tfile=&quot;dravidsp.csv&quot;,ttype=&quot;batting&quot;)</span>
<span>#acooksp = ca.getPlayerDataSp(11728,tdir=&quot;.&quot;,tfile=&quot;acooksp.csv&quot;,ttype=&quot;batting&quot;)</span>
<span>#larasp = ca.getPlayerDataSp(52337,tdir=&quot;.&quot;,tfile=&quot;larasp.csv&quot;,ttype=&quot;batting&quot;)</span>
<span>#kohlisp = ca.getPlayerDataSp(253802,tdir=&quot;.&quot;,tfile=&quot;kohlisp.csv&quot;,ttype=&quot;batting&quot;)</span></code></pre>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanContributionWonLost(<span>&quot;../dravidsp.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<div>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-1.png?w=300" data-attachment-id="6976" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-wonlost-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-wonlost-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6976" data-recalc-dims="1"></p>
<pre><code>ca.batsmanContributionWonLost(<span>&quot;../acooksp.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-2.png?w=300" data-attachment-id="6977" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-wonlost-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-wonlost-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6977" data-recalc-dims="1"></p>
<pre><code>ca.batsmanContributionWonLost(<span>&quot;../larasp.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-3.png?w=300" data-attachment-id="6978" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-wonlost-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-wonlost-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6978" data-recalc-dims="1"></p>
<pre><code>ca.batsmanContributionWonLost(<span>&quot;../kohlisp.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img><br>
<img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-4.png?w=300" data-attachment-id="6979" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-wonlost-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-wonlost-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-wonlost-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6979" data-recalc-dims="1"></p>
</div>
<div>
<h2>13. Performance at home and overseas</h2>
<p>From the plot below it can be seen</p>
<p>Dravid has a higher median overseas than at home.Cook, Lara and Kohli have a lower median of runs overseas than at home.</p>
<p>This function also requires the use of getPlayerDataSp() as shown above</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanPerfHomeAway(<span>&quot;../dravidsp.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<div>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-1.png?w=300" data-attachment-id="6981" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-homeaway-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-homeaway-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6981" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfHomeAway(<span>&quot;../acooksp.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-2.png?w=300" data-attachment-id="6982" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-homeaway-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-homeaway-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6982" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfHomeAway(<span>&quot;../larasp.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-3.png?w=300" data-attachment-id="6983" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-homeaway-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-homeaway-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6983" data-recalc-dims="1"></p>
<pre><code>ca.batsmanPerfHomeAway(<span>&quot;../kohlisp.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-4.png?w=300" data-attachment-id="6984" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/ralk-homeaway-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/ralk-homeaway-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="ralk-homeaway-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6984" data-recalc-dims="1"></p>
</div>
<div>
<h2>14 Moving Average of runs in career</h2>
<p>Take a look at the Moving Average across the career of the Top 4 (ignore the dip at the end of all plots. Need to check why this is so!). Lara’s performance seems to have been quite good before his retirement(wonder why retired so early!). Kohli’s performance has been steadily improving over the years</p>
<div>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanMovingAverage(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-1.png?w=300" data-attachment-id="6985" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-ma-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-ma-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-ma,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6985" data-recalc-dims="1"></p>
<pre><code>ca.batsmanMovingAverage(<span>&quot;../acook.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-2.png?w=300" data-attachment-id="6986" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-ma-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-ma-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-ma,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6986" data-recalc-dims="1"></p>
<pre><code>ca.batsmanMovingAverage(<span>&quot;../lara.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-3.png?w=300" data-attachment-id="6987" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-ma-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-ma-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-ma,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6987" data-recalc-dims="1"></p>
<pre><code>ca.batsmanMovingAverage(<span>&quot;../kohli.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-4.png?w=300" data-attachment-id="6988" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-ma-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-ma-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-ma-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-ma,-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6988" data-recalc-dims="1"></p>
</div>
<div>
<h2>15 Cumulative Average runs of batsman in career</h2>
<p>This function provides the cumulative average runs of the batsman over the career. Dravid averages around 48, Cook around 44, Lara around 50 and Kohli shows a steady improvement in his cumulative average. Kohli seems to be getting better with time.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanCumulativeAverageRuns(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-1.png?w=300" data-attachment-id="6990" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-car-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-car-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-car,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6990" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeAverageRuns(<span>&quot;../acook.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-2.png?w=300" data-attachment-id="6991" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-car-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-car-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-car,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6991" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeAverageRuns(<span>&quot;../lara.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-3.png?w=300" data-attachment-id="6992" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-car-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-car-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-car,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6992" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeAverageRuns(<span>&quot;../kohli.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-4.png?w=300" data-attachment-id="6993" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-car-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-car-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-car-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-car,-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6993" data-recalc-dims="1"></p>
</div>
<div>
<h2>16 Cumulative Average strike rate of batsman in career</h2>
<p>Lara has a terrific strike rate of 52+. Cook has a better strike rate over Dravid. Kohli’s strike rate has improved over the years.</p>
<div>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanCumulativeStrikeRate(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-1.png?w=300" data-attachment-id="6994" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-casr-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-casr-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-casr,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6994" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeStrikeRate(<span>&quot;../acook.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-2.png?w=300" data-attachment-id="6995" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-casr-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-casr-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-casr,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6995" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeStrikeRate(<span>&quot;../lara.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-3.png?w=300" data-attachment-id="6996" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-casr-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-casr-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-casr,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6996" data-recalc-dims="1"></p>
<pre><code>ca.batsmanCumulativeStrikeRate(<span>&quot;../kohli.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-4.png?w=300" data-attachment-id="6997" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-casr-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-casr-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-casr-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-casr,-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6997" data-recalc-dims="1"><br>
<img>17 Future Runs forecast</h2>
<p>Here are plots that forecast how the batsman will perform in future. Currently ARIMA has been used for the forecast. (To do:  Perform Holt-Winters forecast!)</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.batsmanPerfForecast(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<pre><code>##                              ARIMA Model Results                              
## ==============================================================================
## Dep. Variable:                 D.runs   No. Observations:                  284
## Model:                 ARIMA(5, 1, 0)   Log Likelihood               -1522.837
## Method:                       css-mle   S.D. of innovations             51.488
## Date:                Sun, 28 Oct 2018   AIC                           3059.673
## Time:                        09:47:39   BIC                           3085.216
## Sample:                    07-04-1996   HQIC                          3069.914
##                          - 01-24-2012                                         
## ================================================================================
##                    coef    std err          z      P>|z|      [0.025      0.975]
## --------------------------------------------------------------------------------
## const           -0.1336      0.884     -0.151      0.880      -1.867       1.599
## ar.L1.D.runs    -0.7729      0.058    -13.322      0.000      -0.887      -0.659
## ar.L2.D.runs    -0.6234      0.071     -8.753      0.000      -0.763      -0.484
## ar.L3.D.runs    -0.5199      0.074     -7.038      0.000      -0.665      -0.375
## ar.L4.D.runs    -0.3490      0.071     -4.927      0.000      -0.488      -0.210
## ar.L5.D.runs    -0.2116      0.058     -3.665      0.000      -0.325      -0.098
##                                     Roots                                    
## =============================================================================
##                  Real           Imaginary           Modulus         Frequency
## -----------------------------------------------------------------------------
## AR.1            0.5789           -1.1743j            1.3093           -0.1771
## AR.2            0.5789           +1.1743j            1.3093            0.1771
## AR.3           -1.3617           -0.0000j            1.3617           -0.5000
## AR.4           -0.7227           -1.2257j            1.4230           -0.3348
## AR.5           -0.7227           +1.2257j            1.4230            0.3348
## -----------------------------------------------------------------------------
##                 0
## count  284.000000
## mean    -0.306769
## std     51.632947
## min   -106.653589
## 25%    -33.835148
## 50%     -8.954253
## 75%     21.024763
## max    223.152901
## 
## C:\Users\Ganesh\ANACON~1\lib\site-packages\statsmodels\tsa\kalmanf\kalmanfilter.py:646: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
##   if issubdtype(paramsdtype, float):
## C:\Users\Ganesh\ANACON~1\lib\site-packages\statsmodels\tsa\kalmanf\kalmanfilter.py:650: FutureWarning: Conversion of the second argument of issubdtype from `complex` to `np.complexfloating` is deprecated. In future, it will be treated as `np.complex128 == np.dtype(complex).type`.
##   elif issubdtype(paramsdtype, complex):
## C:\Users\Ganesh\ANACON~1\lib\site-packages\statsmodels\tsa\kalmanf\kalmanfilter.py:577: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
##   if issubdtype(paramsdtype, float):</code></pre>
<p><img><img><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-1.png?w=300" data-attachment-id="6999" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/perffcstcache-true-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="perffcst,cache-TRUE-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-6999" data-recalc-dims="1"></p>
</div>
<div>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-2.png?w=300" data-attachment-id="7000" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/perffcstcache-true-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/perffcstcache-true-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="perffcst,cache-TRUE-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7000" data-recalc-dims="1"></h2>
<h2>18 Relative Batsman Cumulative Average Runs</h2>
<p>The plot below compares the Relative cumulative average runs of the batsman for each of the runs ranges of 10 and plots them. The plot indicate the following Range 30 – 100 innings – Lara leads followed by Dravid Range 100+ innings – Kohli races ahead of the rest</p>
<div>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
frames = [<span>&quot;../dravid.csv&quot;</span>,<span>&quot;../acook.csv&quot;</span>,<span>&quot;../lara.csv&quot;</span>,<span>&quot;../kohli.csv&quot;</span>]
names = [<span>&quot;Dravid&quot;</span>,<span>&quot;A Cook&quot;</span>,<span>&quot;Brian Lara&quot;</span>,<span>&quot;V Kohli&quot;</span>]
ca.relativeBatsmanCumulativeAvgRuns(frames,names)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-relsr-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-relsr-1.png?w=300" data-attachment-id="7001" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-relsr-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-relsr-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-relsr-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-relSR-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7001" data-recalc-dims="1"></p>
</div>
<div>
<h2>19. Relative Batsman Strike Rate</h2>
<p>The plot below gives the relative Runs Frequency Percetages for each 10 run bucket. The plot below show</p>
<p>Brian Lara towers over the Dravid, Cook and Kohli. However you will notice that Kohli’s strike rate is going up</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
frames = [<span>&quot;../dravid.csv&quot;</span>,<span>&quot;../acook.csv&quot;</span>,<span>&quot;../lara.csv&quot;</span>,<span>&quot;../kohli.csv&quot;</span>]
names = [<span>&quot;Dravid&quot;</span>,<span>&quot;A Cook&quot;</span>,<span>&quot;Brian Lara&quot;</span>,<span>&quot;V Kohli&quot;</span>]
ca.relativeBatsmanCumulativeStrikeRate(frames,names)</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rakl-relrunfreq-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rakl-relrunfreq-1.png?w=300" data-attachment-id="7003" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rakl-relrunfreq-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rakl-relrunfreq-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rakl-relrunfreq-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rakl-relRunFreq-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7003" data-recalc-dims="1"></h2>
<h2>20. 3D plot of Runs vs Balls Faced and Minutes at Crease</h2>
<p>The plot is a scatter plot of Runs vs Balls faced and Minutes at Crease. A prediction plane is fitted</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.battingPerf3d(<span>&quot;../dravid.csv&quot;</span>,<span>&quot;Rahul Dravid&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/plot-3-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/plot-3-1.png?w=300" data-attachment-id="7005" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/plot-3-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/plot-3-1-8/" data-large-file="https://gigadom.files.wordpress.com/2018/10/plot-3-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="plot-3-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7005" data-recalc-dims="1"></p>
<pre><code>ca.battingPerf3d(<span>&quot;../acook.csv&quot;</span>,<span>&quot;Alastair Cook&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/plot-3-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/plot-3-2.png?w=300" data-attachment-id="7006" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/plot-3-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/plot-3-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/plot-3-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="plot-3-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7006" data-recalc-dims="1"></p>
<pre><code>ca.battingPerf3d(<span>&quot;../lara.csv&quot;</span>,<span>&quot;Brian Lara&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/plot-3-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/plot-3-3.png?w=300" data-attachment-id="7007" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/plot-3-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/plot-3-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/plot-3-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="plot-3-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7007" data-recalc-dims="1"></p>
<pre><code>ca.battingPerf3d(<span>&quot;../kohli.csv&quot;</span>,<span>&quot;Virat Kohli&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/plot-3-4.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/plot-3-4.png?w=300" data-attachment-id="7008" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/plot-3-4.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/plot-3-4/" data-large-file="https://gigadom.files.wordpress.com/2018/10/plot-3-4.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="plot-3-4" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7008" data-recalc-dims="1"></p>
<div>
<h2>21. Predicting Runs given Balls Faced and Minutes at Crease</h2>
<p>A multi-variate regression plane is fitted between Runs and Balls faced +Minutes at crease.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>import</span> numpy <span>as</span> np
<span>import</span> pandas <span>as</span> pd
BF = np.linspace( <span>10</span>, <span>400</span>,<span>15</span>)
Mins = np.linspace( <span>30</span>,<span>600</span>,<span>15</span>)
newDF= pd.DataFrame({<span>'BF'</span>:BF,<span>'Mins'</span>:Mins})
dravid = ca.batsmanRunsPredict(<span>&quot;../dravid.csv&quot;</span>,newDF,<span>&quot;Dravid&quot;</span>)</code></pre>
<pre><code>print(dravid)</code></pre>
<pre><code>##             BF        Mins        Runs
## 0    10.000000   30.000000    0.519667
## 1    37.857143   70.714286   13.821794
## 2    65.714286  111.428571   27.123920
## 3    93.571429  152.142857   40.426046
## 4   121.428571  192.857143   53.728173
## 5   149.285714  233.571429   67.030299
## 6   177.142857  274.285714   80.332425
## 7   205.000000  315.000000   93.634552
## 8   232.857143  355.714286  106.936678
## 9   260.714286  396.428571  120.238805
## 10  288.571429  437.142857  133.540931
## 11  316.428571  477.857143  146.843057
## 12  344.285714  518.571429  160.145184
## 13  372.142857  559.285714  173.447310
## 14  400.000000  600.000000  186.749436</code></pre>
<p>The fitted model is then used to predict the runs that the batsmen will score for a given Balls faced and Minutes at crease.</p>
</div>
<div>
<h2>22 Analysis of Top 3 wicket takers</h2>
<p>The following 3 bowlers have had an excellent career and will be used for the analysis</p>
<ol>
<li>Glenn McGrath:Wickets: 563, Average = 21.64, Economy Rate – 2.49</li>
<li>Kapil Dev : Wickets: 434, Average = 29.64, Economy Rate – 2.78</li>
<li>James Anderson: Wickets: 564, Average = 28.64, Economy Rate – 2.88</li>
</ol>
<p>How do Glenn McGrath, Kapil Dev and James Anderson compare with one another with respect to wickets taken and the Economy Rate. The next set of plots compute and plot precisely these analyses.</p>
</div>
<div>
<h2>23. Get the bowler’s data</h2>
<p>This plot below computes the percentage frequency of number of wickets taken for e.g 1 wicket x%, 2 wickets y% etc and plots them as a continuous line</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>#mcgrath =ca.getPlayerData(6565,dir=&quot;.&quot;,file=&quot;mcgrath.csv&quot;,type=&quot;bowling&quot;,homeOrAway=[1,2], result=[1,2,4])</span>
<span>#kapil =ca.getPlayerData(30028,dir=&quot;.&quot;,file=&quot;kapil.csv&quot;,type=&quot;bowling&quot;,homeOrAway=[1,2], result=[1,2,4])</span>
<span>#anderson =ca.getPlayerData(8608,dir=&quot;.&quot;,file=&quot;anderson.csv&quot;,type=&quot;bowling&quot;,homeOrAway=[1,2], result=[1,2,4])</span></code></pre>
</div>
<div>
<h2>24. Wicket Frequency Plot</h2>
<p>This plot below plots the frequency of wickets taken for each of the bowlers</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerWktsFreqPercent(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-1.png?w=300" data-attachment-id="7009" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/relbowlfp-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/relbowlfp-1-7/" data-large-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="relBowlFP,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7009" data-recalc-dims="1"></p>
<pre><code>ca.bowlerWktsFreqPercent(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-2.png?w=300" data-attachment-id="7010" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/relbowlfp-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/relbowlfp-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="relBowlFP,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7010" data-recalc-dims="1"></p>
<pre><code>ca.bowlerWktsFreqPercent(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-3.png?w=300" data-attachment-id="7011" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/relbowlfp-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/relbowlfp-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/relbowlfp-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="relBowlFP,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7011" data-recalc-dims="1"></p>
<h2>25. Wickets Runs plot</h2>
<p>The plot below create a box plot showing the 1st and 3rd quartile of runs conceded versus the number of wickets taken</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerWktsRunsPlot(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-1.png?w=300" data-attachment-id="7013" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/wktsrun-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/wktsrun-1-7/" data-large-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="wktsrun-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7013" data-recalc-dims="1"></p>
<pre><code>ca.bowlerWktsRunsPlot(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-2.png?w=300" data-attachment-id="7014" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/wktsrun-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/wktsrun-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="wktsrun-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7014" data-recalc-dims="1"></p>
<pre><code>ca.bowlerWktsRunsPlot(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-3.png?w=300" data-attachment-id="7015" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/wktsrun-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/wktsrun-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/wktsrun-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="wktsrun-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7015" data-recalc-dims="1"></p>
<h2>26 Average wickets at different venues</h2>
<p>The plot gives the average wickets taken by Muralitharan at different venues. McGrath best performances are at Centurion, Lord’s and Port of Spain averaging about 4 wickets. Kapil Dev’s does good at Kingston and Wellington. Anderson averages 4 wickets at Dunedin and Nagpur</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerAvgWktsGround(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-1.png?w=300" data-attachment-id="7016" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktshrg-1-6/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktshrg,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7016" data-recalc-dims="1"></p>
<pre><code>ca.bowlerAvgWktsGround(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-2.png?w=300" data-attachment-id="7017" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktshrg-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktshrg,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7017" data-recalc-dims="1"></p>
<pre><code>ca.bowlerAvgWktsGround(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-3.png?w=300" data-attachment-id="7018" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktshrg-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktshrg-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktshrg,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7018" data-recalc-dims="1"></p>
<h2>27 Average wickets against different opposition</h2>
<p>The plot gives the average wickets taken by Muralitharan against different countries. The x-axis also includes the number of innings against each team</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerAvgWktsOpposition(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-1.png?w=300" data-attachment-id="7020" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktoppn-1-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktoppn-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7020" data-recalc-dims="1"></p>
<pre><code>ca.bowlerAvgWktsOpposition(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-2.png?w=300" data-attachment-id="7021" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktoppn-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktoppn-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7021" data-recalc-dims="1"></p>
<pre><code>ca.bowlerAvgWktsOpposition(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-3.png?w=300" data-attachment-id="7022" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/avgwktoppn-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/avgwktoppn-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="avgWktoppn-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7022" data-recalc-dims="1"></p>
<h2>28 Wickets taken moving average</h2>
<p>From the plot below it can be see James Anderson has had a solid performance over the years averaging about wickets</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerMovingAverage(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-1.png?w=300" data-attachment-id="7023" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlma-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlma,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7023" data-recalc-dims="1"></p>
<pre><code>ca.bowlerMovingAverage(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-2.png?w=300" data-attachment-id="7024" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlma-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlma,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7024" data-recalc-dims="1"></p>
<pre><code>ca.bowlerMovingAverage(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-3.png?w=300" data-attachment-id="7025" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlma-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlma-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlma,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7025" data-recalc-dims="1"></p>
<h2>29 Cumulative average wickets taken</h2>
<p>The plots below give the cumulative average wickets taken by the bowlers. mcGrath plateaus around 2.4 wickets, Kapil Dev’s performance deteriorates over the years. Anderson holds on rock steady around 2 wickets</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerCumulativeAvgWickets(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-1.png?w=300" data-attachment-id="7027" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlcaw-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlcaw,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7027" data-recalc-dims="1"></p>
<pre><code>ca.bowlerCumulativeAvgWickets(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-2.png?w=300" data-attachment-id="7028" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlcaw-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlcaw,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7028" data-recalc-dims="1"></p>
<pre><code>ca.bowlerCumulativeAvgWickets(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-3.png?w=300" data-attachment-id="7029" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowlcaw-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowlcaw-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowlcaw,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7029" data-recalc-dims="1"></p>
<h2>30 Cumulative average economy rate</h2>
<p>The plots below give the cumulative average economy rate of the bowlers. McGrath’s was very expensive early in his career conceding about 2.8 runs per over which drops to around 2.5 runs towards the end. Kapil Dev’s economy rate drops from 3.6 to 2.8. Anderson is probably more expensive than the other 2.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerCumulativeAvgEconRate(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-1.png?w=300" data-attachment-id="7031" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowler-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowler-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowler,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7031" data-recalc-dims="1"></p>
<pre><code>ca.bowlerCumulativeAvgEconRate(<span>&quot;../kapil.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-2.png?w=300" data-attachment-id="7032" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowler-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowler-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowler,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7032" data-recalc-dims="1"></p>
<pre><code>ca.bowlerCumulativeAvgEconRate(<span>&quot;../anderson.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-3.png?w=300" data-attachment-id="7033" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-bowler-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-bowler-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-bowler-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-bowler,-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7033" data-recalc-dims="1"></p>
<h2>31 Future Wickets forecast</h2>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerPerfForecast(<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<pre><code>##                              ARIMA Model Results                              
## ==============================================================================
## Dep. Variable:              D.Wickets   No. Observations:                  236
## Model:                 ARIMA(5, 1, 0)   Log Likelihood                -480.815
## Method:                       css-mle   S.D. of innovations              1.851
## Date:                Sun, 28 Oct 2018   AIC                            975.630
## Time:                        09:28:32   BIC                            999.877
## Sample:                    11-12-1993   HQIC                           985.404
##                          - 01-02-2007                                         
## ===================================================================================
##                       coef    std err          z      P>|z|      [0.025      0.975]
## -----------------------------------------------------------------------------------
## const               0.0037      0.033      0.113      0.910      -0.061       0.068
## ar.L1.D.Wickets    -0.9432      0.064    -14.708      0.000      -1.069      -0.818
## ar.L2.D.Wickets    -0.7254      0.086     -8.469      0.000      -0.893      -0.558
## ar.L3.D.Wickets    -0.4827      0.093     -5.217      0.000      -0.664      -0.301
## ar.L4.D.Wickets    -0.3690      0.085     -4.324      0.000      -0.536      -0.202
## ar.L5.D.Wickets    -0.1709      0.064     -2.678      0.008      -0.296      -0.046
##                                     Roots                                    
## =============================================================================
##                  Real           Imaginary           Modulus         Frequency
## -----------------------------------------------------------------------------
## AR.1            0.5630           -1.2761j            1.3948           -0.1839
## AR.2            0.5630           +1.2761j            1.3948            0.1839
## AR.3           -0.8433           -1.0820j            1.3718           -0.3554
## AR.4           -0.8433           +1.0820j            1.3718            0.3554
## AR.5           -1.5981           -0.0000j            1.5981           -0.5000
## -----------------------------------------------------------------------------
##                 0
## count  236.000000
## mean    -0.005142
## std      1.856961
## min     -3.457002
## 25%     -1.433391
## 50%     -0.080237
## 75%      1.446149
## max      5.840050</code></pre>
<div>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-1.png?w=300" data-attachment-id="7034" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-perffcst-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-perffcst,-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7034" data-recalc-dims="1"></h2>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-2.png?w=300" data-attachment-id="7035" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-perffcst-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-perffcst-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-perffcst,-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7035" data-recalc-dims="1"></h2>
<h2>32 Get player data special</h2>
<p>As discussed above the next 2 charts require the use of getPlayerDataSp()</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
<span>#mcgrathsp =ca.getPlayerDataSp(6565,tdir=&quot;.&quot;,tfile=&quot;mcgrathsp.csv&quot;,ttype=&quot;bowling&quot;)</span>
<span>#kapilsp =ca.getPlayerDataSp(30028,tdir=&quot;.&quot;,tfile=&quot;kapilsp.csv&quot;,ttype=&quot;bowling&quot;)</span>
<span>#andersonsp =ca.getPlayerDataSp(8608,tdir=&quot;.&quot;,tfile=&quot;andersonsp.csv&quot;,ttype=&quot;bowling&quot;)</span></code></pre>
</div>
<div>
<h2>33 Contribution to matches won and lost</h2>
<p>The plot below is extremely interesting Glenn McGrath has been more instrumental in Australia winning than Kapil and Anderson as seems to have taken more wickets when Australia won.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerContributionWonLost(<span>&quot;../mcgrathsp.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-1.png?w=300" data-attachment-id="7037" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-wl-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-wl-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-wl-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7037" data-recalc-dims="1"></p>
<pre><code>ca.bowlerContributionWonLost(<span>&quot;../kapilsp.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-2.png?w=300" data-attachment-id="7038" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-wl-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-wl-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-wl-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7038" data-recalc-dims="1"></p>
<pre><code>ca.bowlerContributionWonLost(<span>&quot;../andersonsp.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-3.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-3.png?w=300" data-attachment-id="7039" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-wl-3.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-wl-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-3.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-wl-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7039" data-recalc-dims="1"></p>
<h2>34 Performance home and overseas</h2>
<p>McGrath and Kapil Dev have performed better overseas than at home. Anderson has performed about the same home and overseas</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
ca.bowlerPerfHomeAway(<span>&quot;../mcgrathsp.csv&quot;</span>,<span>&quot;Glenn McGrath&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-1.png?w=300" data-attachment-id="7041" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-ha-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-ha-1/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-ha-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7041" data-recalc-dims="1"></p>
<pre><code>ca.bowlerPerfHomeAway(<span>&quot;../kapilsp.csv&quot;</span>,<span>&quot;Kapil Dev&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-2.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-2.png?w=300" data-attachment-id="7042" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-ha-2.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-ha-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-ha-2.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-ha-2" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7042" data-recalc-dims="1"></p>
<pre><code>ca.bowlerPerfHomeAway(<span>&quot;../andersonsp.csv&quot;</span>,<span>&quot;James Anderson&quot;</span>)</code></pre>
<p><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-31.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-31.png?w=300" data-attachment-id="7043" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/mka-wl-31.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/mka-wl-3-2/" data-large-file="https://gigadom.files.wordpress.com/2018/10/mka-wl-31.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="mka-wl-3" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7043" data-recalc-dims="1"></p>
<h2>35 Relative cumulative average economy rate of bowlers</h2>
<p>The Relative cumulative economy rate shows that McGrath has the best economy rate followed by Kapil Dev and then Anderson.</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
frames = [<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;../kapil.csv&quot;</span>,<span>&quot;../anderson.csv&quot;</span>]
names = [<span>&quot;Glenn McGrath&quot;</span>,<span>&quot;Kapil Dev&quot;</span>,<span>&quot;James Anderson&quot;</span>]
ca.relativeBowlerCumulativeAvgEconRate(frames,names)</code></pre>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/relbowlperf-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/relbowlperf-1.png?w=300" data-attachment-id="7045" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/relbowlperf-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/relbowlperf-1-8/" data-large-file="https://gigadom.files.wordpress.com/2018/10/relbowlperf-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="relBowlPerf-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7045" data-recalc-dims="1"></h2>
<h2>36 Relative Economy Rate against wickets taken</h2>
<p>McGrath has been economical regardless of the number of wickets taken. Kapil Dev has been slightly more expensive when he takes more wickets</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
frames = [<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;../kapil.csv&quot;</span>,<span>&quot;../anderson.csv&quot;</span>]
names = [<span>&quot;Glenn McGrath&quot;</span>,<span>&quot;Kapil Dev&quot;</span>,<span>&quot;James Anderson&quot;</span>]
ca.relativeBowlingER(frames,names)</code></pre>
<h2><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/relbowler-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/relbowler-1.png?w=300" data-attachment-id="7046" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/relbowler-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/relbowler-1-8/" data-large-file="https://gigadom.files.wordpress.com/2018/10/relbowler-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="relBowlER-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7046" data-recalc-dims="1"></h2>
<h2>37 Relative cumulative average wickets of bowlers in career</h2>
<p>The plot below shows that McGrath has the best overall cumulative average wickets. Kapil’s leads Anderson till about 150 innings after which Anderson takes over</p>
<pre><code><span>import</span> cricpy.analytics <span>as</span> ca
frames = [<span>&quot;../mcgrath.csv&quot;</span>,<span>&quot;../kapil.csv&quot;</span>,<span>&quot;../anderson.csv&quot;</span>]
names = [<span>&quot;Glenn McGrath&quot;</span>,<span>&quot;Kapil Dev&quot;</span>,<span>&quot;James Anderson&quot;</span>]
ca.relativeBowlerCumulativeAvgWickets(frames,names)</code></pre>
<h1><img data-orig-file="https://gigadom.files.wordpress.com/2018/10/rbcaw-1.png" data-orig-size="1920,1152" data-medium-file="https://gigadom.files.wordpress.com/2018/10/rbcaw-1.png?w=300" data-attachment-id="7047" data-image-meta="{" data-image-description="" src="https://gigadom.files.wordpress.com/2018/10/rbcaw-1.png?w=450&h=406&fit=676%2C406" data-permalink="https://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/rbcaw-1-3/" data-large-file="https://gigadom.files.wordpress.com/2018/10/rbcaw-1.png?w=450&amp;h=406&amp;fit=676%2C406" alt="" data-image-title="rbcaw-1" sizes="(max-width: 676px) 100vw, 676px" data-comments-opened="1" class="wp-image-7047" data-recalc-dims="1"></h1>
<h1>Key Findings</h1>
<p>The plots above capture some of the capabilities and features of my <strong>cricpy</strong> package. Feel free to install the package and try it out. Please do keep in mind ESPN Cricinfo’s Terms of Use.</p>
<p>Here are the main findings from the analysis above</p>
<div>
<h2>Key insights</h2>
<p>1. Brian Lara is head and shoulders above the rest in the overall strike rate<br>
2. Kohli performance has been steadily improving over the years and with the way he is going he will shatter all records.<br>
3. Kohli and Dravid have scored more in matches where India has won than the other two.<br>
4. Dravid has performed very well overseas<br>
5. The cumulative average runs has Kohli just edging out the other 3. Kohli is probably midway in his career but considering that his moving average is improving strongly, we can expect great things of him with the way he is going.<br>
6. McGrath has had some great performances overseas<br>
7. Mcgrath has the best economy rate and has contributed significantly to Australia’s wins.<br>
8.In the cumulative average wickets race McGrath leads the pack. Kapil leads Anderson till about 150 matches after which Anderson takes over.</p>
<p>The code for cricpy can be accessed at Github at <a rel="nofollow" href="https://github.com/tvganesh/cricpy" target="_blank">cricpy</a></p>
<p>Do let me know if you run into issues.</p>
<h2>Conclusion</h2>
<p>I have long wanted to make a python equivalent of cricketr and I have been able to make it. cricpy is still work in progress. I have add the necessary functions for ODI and Twenty20.  Go ahead give ‘cricpy’ a spin!!</p>
</div>
<p>Stay tuned!</p>
<div>
<p>You may also like<br>
1. <a rel="nofollow" href="http://my%20book%20%E2%80%9Cdeep%20learning%20from%20first%20principles%E2%80%9D%20now%20on%20amazon/" target="_blank">My book “Deep Learning from first principles” now on Amazon</a><br>
2.<a rel="nofollow" href="https://gigadom.in/2018/06/01/my-book-practical-machine-learning-in-r-and-python-second-edition-on-amazon/" target="_blank"> My book ‘Practical Machine Learning in R and Python: Second edition’ on Amazon</a><br>
3. <a rel="nofollow" href="https://gigadom.in/2016/06/23/introducing-qcsimulator-a-5-qubit-quantum-computing-simulator-in-r/" target="_blank">Introducing QCSimulator: A 5-qubit quantum computing simulator in R</a><br>
4. <a rel="nofollow" href="https://gigadom.in/2011/11/22/de-blurring-revisited-with-wiener-filter-using-opencv/" target="_blank">De-blurring revisited with Wiener filter using OpenCV</a><br>
5. <a rel="nofollow" href="https://gigadom.in/2014/08/07/spicing-up-a-ibm-bluemix-cloud-app-with-mongodb-and-nodeexpress/" target="_blank">Spicing up a IBM Bluemix cloud app with MongoDB and NodeExpress</a><br>
6. <a rel="nofollow" href="https://gigadom.in/2015/11/29/sixer-r-package-cricketrs-new-avatar/" target="_blank">Sixer – R package cricketr’s new Shiny avatar</a><br>
7. <a rel="nofollow" href="https://gigadom.in/2013/06/07/simulating-an-edge-shape-in-android/" target="_blank">Simulating an Edge Shape in Android</a></p>
<p>To see all posts click <a rel="nofollow" href="https://gigadom.in/aa-2/" target="_blank">Index of Posts</a></p>
</div>
</div>
</div>
</div>
</div>
	<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://gigadom.in/2018/10/28/introducing-cricpya-python-package-to-analyze-performances-of-cricketrs/"> R – Giga thoughts …</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/RhE7ZH5xFyY" height="1"></a></div>