<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Tumuhimbise Moses on Medium]]></title>
        <description><![CDATA[Stories by Tumuhimbise Moses on Medium]]></description>
        <link>https://medium.com/@tumuhimbisemoses?source=rss-763aa58379de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2bkTttva7ncr_7Qb.</url>
            <title>Stories by Tumuhimbise Moses on Medium</title>
            <link>https://medium.com/@tumuhimbisemoses?source=rss-763aa58379de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:34:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tumuhimbisemoses/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hitting dead ends, a tale of transcribeR.]]></title>
            <link>https://medium.com/@tumuhimbisemoses/hitting-dead-ends-a-tale-of-transcriber-645b502df164?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/645b502df164</guid>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Fri, 09 Jul 2021 13:07:09 GMT</pubDate>
            <atom:updated>2021-07-09T13:13:52.313Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Hitting dead ends, a tale of transcribeR</strong></h3><p>Stumbled upon the transcribeR package which in its basic description is helpful in automating the process of transcribing audio files using the HP IDOL API. Installation of the package was a success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*Ikmed6NiMLXRoYcP1HSmLA.png" /></figure><p>Using the printLanguages function to reveal the language codes for HP API</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*a6dBHabMRr8pChUQg8PDBA.png" /></figure><p>It is after this that I hit a dead end, the next function retrieveText is supposed to get a text from returned JSON Object. However, am unable to achieve this because am unable to get the API Key used in authenticating the request to HP IDOL on Demand at the now-defunct <a href="https://www.idolondemand.com/">https://www.idolondemand.com/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*e5m6B1BKHD6gpgEQll7zDQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=645b502df164" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to generate, play and solve Sudoku puzzles in R]]></title>
            <link>https://medium.com/@tumuhimbisemoses/how-to-generate-play-and-solve-sudoku-puzzles-in-r-26761b056fe4?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/26761b056fe4</guid>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 15:26:13 GMT</pubDate>
            <atom:updated>2020-03-03T15:26:13.699Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*z0jS8fio2d3jTgj16d91-w.jpeg" /></figure><p>As a non-avid but yet interested player of Sudoku and a lover of the R language, I have always longed for its gaming capabilities. My desire and one evening led me to stumble upon a <a href="https://cran.r-project.org/package=sudoku">Sudoku puzzle generator and solver for R</a>. Besides installing the package itself, one of the prerequisites to begin tinkering with it is for one to install the <a href="https://cran.r-project.org/package=tkrplot">tkrplot package</a>. So basically, the main capabilities of this package are outlined in eight topics;</p><p>· Fetching Sudoku puzzles from the leading online Sudoku portal</p><p>· Generating Sudoku puzzles</p><p>· Utilizing hints to solve Sudoku puzzles</p><p>· Playing Sudoku puzzles in R</p><p>· Printing Sudoku puzzles</p><p>· Reading Sudoku puzzle files</p><p>· Solving Sudoku puzzles</p><p>· Writing Sudoku puzzle files</p><p><strong>Fetching Sudoku puzzles from the leading online Sudoku portal</strong></p><p>This function allows one to fetch daily puzzles from Sudoku.org.uk with the alternative of choosing a puzzle from its archives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*2ffxG9X64p5Di5qqwbVYCQ.png" /></figure><p>The grid created is based on a 9x9 arrangement that is suited for one to play.</p><p><strong>Utilizing hints to solve Sudoku puzzles</strong></p><p>To use this function, one can either press the h key while holding/hovering the mouse above the desired grid. In this case, I placed the mouse over the second cell of the second row in the second column. To this, I was provided with hints as to which value is likely most suited for this cell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*mLckHlHIvKMf_u7NmZDypg.png" /></figure><p>It is important to note that these are hints and not accurate solutions. For instance, I don’t think 5 is the correct value to be placed in this cell. It still remains upon the proficiency of the user/player to choose the most accurate value. I choose 2 (simply by moving the mouse over the desired cell and pressing 2 on the keyboard).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*2Z4ZZ5MtJbnwsOAenNz4rw.png" /></figure><p><strong>Playing Sudoku puzzles in R</strong></p><p>To interactively play a puzzle, one could either fetch one or generate one. In the previous section, we interactively played a puzzle. In the next section, we shall generate a puzzle.</p><p>We can generate our own grid and fill in values accordingly with the following script.</p><pre>some_random_puzzle &lt;- playSudoku(0)</pre><pre>now_let_us_play &lt;- playSudoku(some_random_puzzle)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*pT1LEBcnpnWX-SQfyLQwDA.png" /></figure><p>To fill in the cells, one has to move the mouse over every individual box and press a value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ypARR9MoxvQadWcRQWkIbA.png" /></figure><p>Alternatively, one can use the following script to generate an editor which can be used to also create a puzzle.</p><pre>another_of_ours &lt;- edit(matrix(0,9,9))</pre><pre>solve_it &lt;- playSudoku(another_of_ours)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*O7zsEGNs1uLSADHqrInKfQ.png" /></figure><p>One can even play a puzzle, randomly generated by the computer/package by using this simple statement,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*L6cMrX3hTsrP2BxHETFW7w.png" /></figure><p>which will create a random puzzle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*wXprOEJFy69OFGP92VCcZA.png" /></figure><p><strong>Printing Sudoku puzzles</strong></p><p>After generating a puzzle, one can print it to the terminal using the following one-liner script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*JLCO-eQGDT2scBUbnDKoAA.png" /></figure><p><strong>Reading Sudoku puzzle files</strong></p><p>The following function allows us to read a file comprising of a Sudoku grid. This is how a file looks like when typed manually in notepad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*WX9n-ugf5d0FiaG2uOSI_g.png" /></figure><p>Our file adheres to the 9x9 matrix. To read it, we run the following script. First, make sure you have your working directory set right to avoid “no file errors”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*bNSJf7p2_zad3W8Tw3QKKA.png" /></figure><p>After running the script, you will be presented with a series of values from 1 to 15. This represents the number of cells within the grid. Input these values wisely to allow for the creation of a sensible puzzle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/132/1*EQZ7cWbyF1XrjMVMAQBy6w.png" /></figure><p>I didn’t heed to my own advice and created this 2-year-old child’s idea of a puzzle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*XCN8hE2RjYR1cOnUuANmDg.png" /></figure><p><strong>Solving Sudoku puzzles</strong></p><p>Solving a puzzle is based on a complex algorithm that utilizes the NxNxN array of logicals which are representative of the NxN cells and the N likely elements. Let us trying solving the SudokuUK puzzle we fetched earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*VJFE1muj65VqvLclUdSd8w.png" /></figure><p>For a more clear representation,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*_3Dd8hxY3W_Hb2aBd07nKw.png" /></figure><p><strong>Writing Sudoku puzzle files</strong></p><p>We can also write a generated or fetched Sudoku grid (matrix) to a text file. Let us write the SudokuUK puzzle we fetched earlier to a text file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*QV0iMYmDXc4iN--uzcrQEg.png" /></figure><p>Now we have a Sudoku puzzle matrix written to file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*JG-qUkpsxvm0KVxwFZP8xA.png" /></figure><p>That’s it. Simple to use package for the puzzle lovers. Maybe in the next post, I will share more of R’s gaming capabilities.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26761b056fe4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding clustering using an analogy about apples.]]></title>
            <link>https://medium.com/@tumuhimbisemoses/understanding-clustering-using-an-analogy-about-apples-25e3c80c1959?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/25e3c80c1959</guid>
            <category><![CDATA[clustering-algorithm]]></category>
            <category><![CDATA[multivariate-analysis]]></category>
            <category><![CDATA[k-means]]></category>
            <category><![CDATA[cluster-analysis]]></category>
            <category><![CDATA[data-analysis]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 18:14:10 GMT</pubDate>
            <atom:updated>2019-07-24T18:14:10.835Z</atom:updated>
            <content:encoded><![CDATA[<p>Multivariate is defined as two or more variable quantities. This form of analysis involves two algorithms namely cluster analysis and dimension reduction. The following article will first focus on cluster analysis. This algorithmic approach looks for natural clusters in data. A cluster is defined as a group of similar things positioned or occurring closing together.</p><p>Consider this analogy. Let’s say you had a box of apples of different colors; red, green and mixed colors. Individually picking each color would not only consume time but is likely to entail manifestations of human error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*6t7eFttX87G4LzA3t8qdjQ.jpeg" /></figure><p>However, with cluster analysis, we can segment these different apples according to color. With such information, one can harvest information such as how many apples belong to which color, which color is of the best quality or which color has the least quality.</p><p>This approach is likely used in algorithms all over the internet such as targeted advertising and recommendation engines in platforms mostly those that are based on social media.</p><p>The first step in segmenting or categorizing different variables in a data set is to use a concept known as dimension reduction. This involves taking a large number of variables and reducing them to a few new variables which best describe the data set. For example, for each apple, you might measure average quality, percentage of volume or whatever comes to the imagination of the user. However, if all these variables are highly correlated, you can combine them into one new variable.</p><p>In this instance, if you are measuring 100 characteristics of each of our apples, it is hard to understand groups of our apples just by looking at the data. In this case, clustering can help you automatically pull out these groups.</p><p>It is also important to note that dimension reduction can be thought of as variable reduction. Again, if we have 100 variables about each of our customers, we may do dimension reduction to find main trends in the variables. The it will be much easier for us to understand the patterns of our apples based in the clustered variables instead of the original 100 batch.</p><p>Before we begin clustering, you may want to remove or estimate missing data and rescale the variables for comparability. On this basis, we shall explore several clustering algorithms that one can use to analyze a carefully selected data set since not just any data set is fit to be clustered.</p><p>For this demonstration, we shall use the inbuilt <em>mtcars </em>data set in R which comprises of Motor Trend Car Road Tests information.</p><p>We shall first begin with partitional or partitioning clustering which are techniques applied in categorizing observations in a data set into several groups on the basis of how similar they are. These algorithms need the analyst to be specific in identifying the number of clusters to be generated.</p><p>Libraries need:</p><p><em>factoextra</em> to beautify the visualization of clusters</p><pre>#load data<br>data(“mtcars”)<br>sampleset &lt;- mtcars<br>#remove any missing values<br>sampleset &lt;- na.omit(sampleset)<br>#scale variables<br>sampleset &lt;- scale(sampleset)<br>#ascertain the alternative number of clusters for k-means clustering<br>library(“factoextra”)<br>fviz_nbclust(sampleset,kmeans,method=”gap_stat”)<br>#compute and visualize k-means clustering<br>set.seed(123)<br>km.res &lt;- kmeans(sampleset,3,nstart=25)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*58DnD8wElb3RX987qoUxEQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*0MRGcqlik5uZfN99218D0Q.jpeg" /></figure><pre>#visualize<br>library(“factoextra”)<br>fviz_cluster(km.res,data=sampleset,ellipse.type=”convex”,palette=”jco”,repel=TRUE,ggtheme=theme_minimal())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*ZWMJ8-To0-Wpc6_y4Iua1g.jpeg" /></figure><p>Now you can see how the data is categorized into three clusters based on similarity.</p><p>In the next article, we shall explore another clustering algorithm known as hierarchical agglomerative.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25e3c80c1959" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How can you pick the oranges and apples separably from data sets using R ?]]></title>
            <link>https://medium.com/data-science/how-can-you-pick-the-oranges-and-apples-separably-from-data-sets-using-r-8219b385e0d1?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/8219b385e0d1</guid>
            <category><![CDATA[multivariate]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[k-means]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Wed, 24 Jul 2019 17:55:37 GMT</pubDate>
            <atom:updated>2019-08-05T08:02:58.778Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding clustering using an analogy about apples.</h3><p>Multivariate is defined as two or more variable quantities. This form of analysis involves two algorithms namely cluster analysis and dimension reduction. The following article will first focus on cluster analysis. This algorithmic approach looks for natural clusters in data. A cluster is defined as a group of similar things positioned or occurring closing together.</p><p>Consider this analogy. Let’s say you had a box of apples of different colors; red, green and mixed colors. Individually picking each color would not only consume time but is likely to entail manifestations of human error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*6t7eFttX87G4LzA3t8qdjQ.jpeg" /></figure><p>However, with cluster analysis, we can segment these different apples according to color. With such information, one can harvest information such as how many apples belong to which color, which color is of the best quality or which color has the least quality.</p><p>This approach is likely used in algorithms all over the internet such as targeted advertising and recommendation engines in platforms mostly those that are based on social media.</p><p>The first step in segmenting or categorizing different variables in a data set is to use a concept known as dimension reduction. This involves taking a large number of variables and reducing them to a few new variables which best describe the data set. For example, for each apple, you might measure average quality, percentage of volume or whatever comes to the imagination of the user. However, if all these variables are highly correlated, you can combine them into one new variable.</p><p>In this instance, if you are measuring 100 characteristics of each of our apples, it is hard to understand groups of our apples just by looking at the data. In this case, clustering can help you automatically pull out these groups.</p><p>It is also important to note that dimension reduction can be thought of as variable reduction. Again, if we have 100 variables about each of our customers, we may do dimension reduction to find main trends in the variables. The it will be much easier for us to understand the patterns of our apples based in the clustered variables instead of the original 100 batch.</p><p>Before we begin clustering, you may want to remove or estimate missing data and rescale the variables for comparability. On this basis, we shall explore several clustering algorithms that one can use to analyze a carefully selected data set since not just any data set is fit to be clustered.</p><p>For this demonstration, we shall use the inbuilt <em>mtcars </em>data set in R which comprises of Motor Trend Car Road Tests information.</p><p>We shall first begin with partitional or partitioning clustering which are techniques applied in categorizing observations in a data set into several groups on the basis of how similar they are. These algorithms need the analyst to be specific in identifying the number of clusters to be generated.</p><p>Libraries need:</p><p><em>factoextra</em> to beautify the visualization of clusters</p><pre>#load data<br>data(“mtcars”)<br>sampleset &lt;- mtcars<br>#remove any missing values<br>sampleset &lt;- na.omit(sampleset)<br>#scale variables<br>sampleset &lt;- scale(sampleset)<br>#ascertain the alternative number of clusters for k-means clustering<br>library(“factoextra”)<br>fviz_nbclust(sampleset,kmeans,method=”gap_stat”)<br>#compute and visualize k-means clustering<br>set.seed(123)<br>km.res &lt;- kmeans(sampleset,3,nstart=25)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*58DnD8wElb3RX987qoUxEQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*0MRGcqlik5uZfN99218D0Q.jpeg" /></figure><pre>#visualize<br>library(“factoextra”)<br>fviz_cluster(km.res,data=sampleset,ellipse.type=”convex”,palette=”jco”,repel=TRUE,ggtheme=theme_minimal())</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*ZWMJ8-To0-Wpc6_y4Iua1g.jpeg" /></figure><p>Now you can see how the data is categorized into three clusters based on similarity.</p><p>In the next article, we shall explore another clustering algorithm known as hierarchical agglomerative.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8219b385e0d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-can-you-pick-the-oranges-and-apples-separably-from-data-sets-using-r-8219b385e0d1">How can you pick the oranges and apples separably from data sets using R ?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Can we create music using R ?]]></title>
            <link>https://medium.com/@tumuhimbisemoses/can-we-create-music-using-r-922bb1f229ed?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/922bb1f229ed</guid>
            <category><![CDATA[audio]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Wed, 27 Feb 2019 15:45:05 GMT</pubDate>
            <atom:updated>2019-02-27T15:45:05.552Z</atom:updated>
            <content:encoded><![CDATA[<h3>Can we create music using R ?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/402/1*3BBFAWl39NXFxxRPre-I1A.jpeg" /><figcaption>sourced from sonic pi.net</figcaption></figure><p>While tinkering with the AudiolyzR package that translates statistical graphs in audio files, I experienced learner’s “block” challenges. Not let down by my limited learning curve, I searched for a relevant audio analysis package in R. This led to <a href="https://www.rdocumentation.org/packages/tuneR/versions/1.3.3">tuneR</a> , an MFCC () attributes package. For a basic level of audio analysis, a simpler approach would be to settle to learning how to create sample audio files using sine (left and right)values.</p><p>We shall begin with importing the tuneR package, after downloading and installing it of course.</p><pre>library(tuneR)</pre><p>The first step is to develop a mono wave object with a playing length of 2 seconds. It will contain the sinus sound folled in 440Hz and 220Hz.</p><pre>Wobj &lt;- bind(sine(100),sine(20))</pre><p>Next, we want to have a look at some of the attributes of the audio file we are attempting to generate.</p><pre>show(Wobj)</pre><p>From the generated characteristics information generated, we can now begin to understand some of the features of the audio file we seek to generate.</p><pre>## <br>## Wave Object<br>##  Number of Samples:      88200<br>##  Duration (seconds):     2<br>##  Samplingrate (Hertz):   44100<br>##  Channels (Mono/Stereo): Mono<br>##  PCM (integer format):   FALSE<br>##  Bit (8/16/24/32/64):    32</pre><p>We already know that our file will be 2 seconds in length, it will have a sample rate of 44100Hz, the channel at which it will operate is Mono and be based on a 32bit architecture.</p><p>It would be interesting to understand how 8bit audio files can be generated. Possible applications of such would be chiptune music.</p><p>On the other hand, it also comes in handy to have a graphical plot as a means of making sense of the entire stuff.</p><pre>plot(extractWave(Wobj, from=1, to=500))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgfPNx17_DrfgjmdZJkDQw.jpeg" /></figure><p>Now that we have generated our audio file, let us try to have a listen to it.</p><pre>play(Wobj)</pre><p>Have a listen at the audio file generated based on the sinus values used in this code.</p><p><a href="https://soundcloud.com/eclnqb6l36nc/audio-testfile-generated-with-tuner">Audio testfile generated with tuneR</a></p><p>We can also solve it but storing the generated file into the C:/ directory of Windows.</p><pre>tmpfile &lt;- file.path(&#39;c:/&#39;,&quot;testfile.mp3&quot;)<br>writeWave(Wobj, tmpfile)</pre><p>R comes in handy by providing us with the location of the generated file.</p><pre>## [1] &quot;c://testfile.mp3&quot;</pre><p>It should be noted that we can substitute .mp3 for .wav or .ogg according to the user’s preference.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=922bb1f229ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[YouTube Data Mining : Experiences of using R.]]></title>
            <link>https://medium.com/@tumuhimbisemoses/youtube-data-mining-experiences-of-using-r-1419e9aefcc5?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/1419e9aefcc5</guid>
            <category><![CDATA[r-tutorial]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[tuber]]></category>
            <category><![CDATA[you-tube-data-mining]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 10:37:51 GMT</pubDate>
            <atom:updated>2018-02-09T10:50:06.358Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*75680um382cAKIqbt112jw.jpeg" /><figcaption>Are you are risk taker ?</figcaption></figure><p>You Tube as any other social media platform provides a rich trove of data. One can put use of such information in many ways. Tickled by the curiosity of the popularity of well known domestic and international stand up comedian Anne Kansiime, I took upon the challenge of scraping data from her You Tube channel with the hope that I could provide some statistically driven insights into the notoriety of her online content. R providers a package known as tuber with the latest version available for download through the CRAN repository.</p><p>After installing the package, we load it into our development environment and then any tinkering with this impressive tool can begin.</p><pre>library (tuber)</pre><p>Before the tuber package can be used fully, perquisites demand that one holds Google Developer Console credentials so as to allow one to access the You Tube API. I found the following <a href="https://help.aolonnetwork.com/hc/en-us/articles/218079623-How-to-Create-Your-YouTube-API-Credentials">tutorial</a> (with step by step images) useful to setting up You Tube Oauth details.</p><p>I recommend testing whether you can connect to the You Tube API with ease as the first step before any data scraping. The following snippet below is helpful in determining whether you were able to correct generate the required API credentials.</p><pre>app_id &lt;- &quot;1088891801215-srtv9mvhb4dt1qr62254vfcgqfg9cp33.apps.googleusercontent.com&quot;<br>app_secret &lt;- &quot;hyJRTIMMvnBNj6WKE6jIzcXa&quot;<br>yt_oauth(app_id, app_secret)</pre><p>After successfully connecting to the API, you should be redirected to the following web page with the following message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*ygLe7H1utgSd8PftO9GGhQ.jpeg" /></figure><p>Now on to the data scraping. I began by extracting the statistics of a single video. In order to do this, I got the video id. A You Tube video id entails the alpha numeric figures after the equals sign within the link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*F_dFtdS4gngAwaz_DQzXtA.jpeg" /></figure><pre>get_stats(video_id=&#39;8XAfjB0fVas&#39;)</pre><p>With the video id, we can now extract some statistics of the video using the line below. I chose to place the newly extracted data in a data frame for easy referencing.</p><pre>## Auto-refreshing stale OAuth token.</pre><p>From the information extracted, we can see that this particular video was viewed 479,534 times, was liked 2,319 times, was disliked 110 times and 185 comments were made. Additional details about the video can be extracted using the get_video_details(video_id=’’) snippet.</p><pre>## $id<br>## [1] &quot;8XAfjB0fVas&quot;<br>## <br>## $viewCount<br>## [1] &quot;479587&quot;<br>## <br>## $likeCount<br>## [1] &quot;2320&quot;<br>## <br>## $dislikeCount<br>## [1] &quot;110&quot;<br>## <br>## $favoriteCount<br>## [1] &quot;0&quot;<br>## <br>## $commentCount<br>## [1] &quot;185&quot;</pre><p>This provides information such as the video initial upload was on 3rd October 2015. Other information includes some of the tags embedded to increase search engine optimization.</p><pre>## $kind<br>## [1] &quot;youtube#videoListResponse&quot;<br>## <br>## $etag<br>## [1] &quot;\&quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/ayTSBFkx2upWmbCv6oiJb0G2whI\&quot;&quot;<br>## <br>## $pageInfo<br>## $pageInfo$totalResults<br>## [1] 1<br>## <br>## $pageInfo$resultsPerPage<br>## [1] 1<br>## <br>## <br>## $items<br>## $items[[1]]<br>## $items[[1]]$kind<br>## [1] &quot;youtube#video&quot;<br>## <br>## $items[[1]]$etag<br>## [1] &quot;\&quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/nkwqeVQVP71TP-Q6Q19srEiC2gM\&quot;&quot;<br>## <br>## $items[[1]]$id<br>## [1] &quot;8XAfjB0fVas&quot;<br>## <br>## $items[[1]]$snippet<br>## $items[[1]]$snippet$publishedAt<br>## [1] &quot;2015-10-03T06:32:44.000Z&quot;<br>## <br>## $items[[1]]$snippet$channelId<br>## [1] &quot;UCd3zZSCsHS-7smn2HwgM0FA&quot;<br>## <br>## $items[[1]]$snippet$title<br>## [1] &quot;Kansiime will not be donating any blood. Kansiime Anne.  African comedy.&quot;<br>## <br>## $items[[1]]$snippet$description<br>## [1] &quot;What!!? U have not Subscribed yet??? Eh nga you are a RISK -TAKER!!\nNOW NEW CLIPS EVERY WEEK !!!\npls also like me on facebook\nhttps://www.facebook.com/pages/Kansiime-Anne-Entertainer/263758240421584?ref=ts&amp;fref=ts&quot;<br>## <br>## $items[[1]]$snippet$thumbnails<br>## $items[[1]]$snippet$thumbnails$default<br>## $items[[1]]$snippet$thumbnails$default$url<br>## [1] &quot;https://i.ytimg.com/vi/8XAfjB0fVas/default.jpg&quot;<br>## <br>## $items[[1]]$snippet$thumbnails$default$width<br>## [1] 120<br>## <br>## $items[[1]]$snippet$thumbnails$default$height<br>## [1] 90<br>## <br>## <br>## $items[[1]]$snippet$thumbnails$medium<br>## $items[[1]]$snippet$thumbnails$medium$url<br>## [1] &quot;https://i.ytimg.com/vi/8XAfjB0fVas/mqdefault.jpg&quot;<br>## <br>## $items[[1]]$snippet$thumbnails$medium$width<br>## [1] 320<br>## <br>## $items[[1]]$snippet$thumbnails$medium$height<br>## [1] 180<br>## <br>## <br>## $items[[1]]$snippet$thumbnails$high<br>## $items[[1]]$snippet$thumbnails$high$url<br>## [1] &quot;https://i.ytimg.com/vi/8XAfjB0fVas/hqdefault.jpg&quot;<br>## <br>## $items[[1]]$snippet$thumbnails$high$width<br>## [1] 480<br>## <br>## $items[[1]]$snippet$thumbnails$high$height<br>## [1] 360<br>## <br>## <br>## $items[[1]]$snippet$thumbnails$standard<br>## $items[[1]]$snippet$thumbnails$standard$url<br>## [1] &quot;https://i.ytimg.com/vi/8XAfjB0fVas/sddefault.jpg&quot;<br>## <br>## $items[[1]]$snippet$thumbnails$standard$width<br>## [1] 640<br>## <br>## $items[[1]]$snippet$thumbnails$standard$height<br>## [1] 480<br>## <br>## <br>## $items[[1]]$snippet$thumbnails$maxres<br>## $items[[1]]$snippet$thumbnails$maxres$url<br>## [1] &quot;https://i.ytimg.com/vi/8XAfjB0fVas/maxresdefault.jpg&quot;<br>## <br>## $items[[1]]$snippet$thumbnails$maxres$width<br>## [1] 1280<br>## <br>## $items[[1]]$snippet$thumbnails$maxres$height<br>## [1] 720<br>## <br>## <br>## <br>## $items[[1]]$snippet$channelTitle<br>## [1] &quot;Kansiime Anne&quot;<br>## <br>## $items[[1]]$snippet$tags<br>## $items[[1]]$snippet$tags[[1]]<br>## [1] &quot;kansime&quot;<br>## <br>## $items[[1]]$snippet$tags[[2]]<br>## [1] &quot;Anne&quot;<br>## <br>## $items[[1]]$snippet$tags[[3]]<br>## [1] &quot;Kansiime&quot;<br>## <br>## $items[[1]]$snippet$tags[[4]]<br>## [1] &quot;ann&quot;<br>## <br>## $items[[1]]$snippet$tags[[5]]<br>## [1] &quot;Ugandan&quot;<br>## <br>## $items[[1]]$snippet$tags[[6]]<br>## [1] &quot;african&quot;<br>## <br>## $items[[1]]$snippet$tags[[7]]<br>## [1] &quot;comedy&quot;<br>## <br>## $items[[1]]$snippet$tags[[8]]<br>## [1] &quot;just&quot;<br>## <br>## $items[[1]]$snippet$tags[[9]]<br>## [1] &quot;for&quot;<br>## <br>## $items[[1]]$snippet$tags[[10]]<br>## [1] &quot;laughs&quot;<br>## <br>## $items[[1]]$snippet$tags[[11]]<br>## [1] &quot;funny&quot;<br>## <br>## $items[[1]]$snippet$tags[[12]]<br>## [1] &quot;gags&quot;<br>## <br>## <br>## $items[[1]]$snippet$categoryId<br>## [1] &quot;23&quot;<br>## <br>## $items[[1]]$snippet$liveBroadcastContent<br>## [1] &quot;none&quot;<br>## <br>## $items[[1]]$snippet$localized<br>## $items[[1]]$snippet$localized$title<br>## [1] &quot;Kansiime will not be donating any blood. Kansiime Anne.  African comedy.&quot;<br>## <br>## $items[[1]]$snippet$localized$description<br>## [1] &quot;What!!? U have not Subscribed yet??? Eh nga you are a RISK -TAKER!!\nNOW NEW CLIPS EVERY WEEK !!!\npls also like me on facebook\nhttps://www.facebook.com/pages/Kansiime-Anne-Entertainer/263758240421584?ref=ts&amp;fref=ts&quot;<br>## <br>## <br>## $items[[1]]$snippet$defaultAudioLanguage<br>## [1] &quot;en&quot;</pre><p>More data can be extracted from the You Tube channel, however in order to achieve this,one needs to known the channel id. I found it difficult to find this information. However, after a few minutes of Stack Overflow browsing, I stumbled upon a You Tube channel name converter by <a href="http://johnnythetank.github.io/youtube-channel-name-converter/">Johnny the Tank</a>.</p><p>You simply type in the channel name and it generates the channel id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*dL5QkFpAq33jPESUd5j5uw.jpeg" /></figure><pre>get_channel_stats(channel_id=&#39;UCd3zZSCsHS-7smn2HwgM0FA&#39;)</pre><p>With the channel id, one can tinker around with functions such as extracting channel statistics. From the output yielded, we observe the channel was first created on 17th April 2012.</p><pre>## Channel Title: Kansiime Anne <br>## No. of Views: 119184892 <br>## No. of Subscribers: 439579 <br>## No. of Videos: 561</pre><p>More video details provided by the function such as date of publish, country of origin, number of overall channel views and number of subscriptions</p><pre>## $kind<br>## [1] &quot;youtube#channel&quot;<br>## <br>## $etag<br>## [1] &quot;\&quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/M_9jAjNkQ6sZhxHyvE2wf59zOqk\&quot;&quot;<br>## <br>## $id<br>## [1] &quot;UCd3zZSCsHS-7smn2HwgM0FA&quot;<br>## <br>## $snippet<br>## $snippet$title<br>## [1] &quot;Kansiime Anne&quot;<br>## <br>## $snippet$description<br>## [1] &quot;NEW CLIPS EVERY WEEK!!!\nAnne Kansiime is a multiple award winning talented comedian, TV presenter, Actress and writer in fun factory, and currently hosts a weekly show on citizen TV Kenya &#39;Dont Mess With Kansiime&#39;.\n\n\&quot;One&#39;s dream job is the kind of job you do without constant reminder that you are working.\&quot;&quot;<br>## <br>## $snippet$publishedAt<br>## [1] &quot;2012-04-17T12:43:23.000Z&quot;<br>## <br>## $snippet$thumbnails<br>## $snippet$thumbnails$default<br>## $snippet$thumbnails$default$url<br>## [1] &quot;https://yt3.ggpht.com/-kJUq6Pvr0bo/AAAAAAAAAAI/AAAAAAAAAAA/8hrTYF7WZnA/s88-c-k-no-mo-rj-c0xffffff/photo.jpg&quot;<br>## <br>## <br>## $snippet$thumbnails$medium<br>## $snippet$thumbnails$medium$url<br>## [1] &quot;https://yt3.ggpht.com/-kJUq6Pvr0bo/AAAAAAAAAAI/AAAAAAAAAAA/8hrTYF7WZnA/s240-c-k-no-mo-rj-c0xffffff/photo.jpg&quot;<br>## <br>## <br>## $snippet$thumbnails$high<br>## $snippet$thumbnails$high$url<br>## [1] &quot;https://yt3.ggpht.com/-kJUq6Pvr0bo/AAAAAAAAAAI/AAAAAAAAAAA/8hrTYF7WZnA/s240-c-k-no-mo-rj-c0xffffff/photo.jpg&quot;<br>## <br>## <br>## <br>## $snippet$localized<br>## $snippet$localized$title<br>## [1] &quot;Kansiime Anne&quot;<br>## <br>## $snippet$localized$description<br>## [1] &quot;NEW CLIPS EVERY WEEK!!!\nAnne Kansiime is a multiple award winning talented comedian, TV presenter, Actress and writer in fun factory, and currently hosts a weekly show on citizen TV Kenya &#39;Dont Mess With Kansiime&#39;.\n\n\&quot;One&#39;s dream job is the kind of job you do without constant reminder that you are working.\&quot;&quot;<br>## <br>## <br>## $snippet$country<br>## [1] &quot;UG&quot;<br>## <br>## <br>## $statistics<br>## $statistics$viewCount<br>## [1] &quot;119184892&quot;<br>## <br>## $statistics$commentCount<br>## [1] &quot;28&quot;<br>## <br>## $statistics$subscriberCount<br>## [1] &quot;439579&quot;<br>## <br>## $statistics$hiddenSubscriberCount<br>## [1] FALSE<br>## <br>## $statistics$videoCount<br>## [1] &quot;561&quot;</pre><p>These along other snippets of information are returned by the code get_channel_stats function. The function below lists all the channel videos. However, since the channel has over 560 videos, we include the max_results parameter to output only 3 results to make a more lean post.</p><pre>list_channel_videos(channel_id = &#39;UCd3zZSCsHS-7smn2HwgM0FA&#39;,max_results = 3)</pre><p>Unfortunately or fortunately, the information provide by this function does not return the videos by title but rather id.</p><pre>##      .id                 kind<br>## 1 items1 youtube#playlistItem<br>## 2 items2 youtube#playlistItem<br>## 3 items3 youtube#playlistItem<br>##                                                        etag<br>## 1 &quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/fTdSB3Ohp0g2uxqyWYBJWzMIZzY&quot;<br>## 2 &quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/0t8YcVKimicXqSPDbjgUtV6Pmdg&quot;<br>## 3 &quot;_gJQceDMxJ8gP-8T2HLXUoURK8c/KCd-nfQNjwkf_gYq9k2Q9-p3AXA&quot;<br>##                                                 id contentDetails.videoId<br>## 1 VVVkM3paU0NzSFMtN3NtbjJId2dNMEZBLjVELWRoVmt2a1pZ            5D-dhVkvkZY<br>## 2 VVVkM3paU0NzSFMtN3NtbjJId2dNMEZBLk9UN0V3QmRYeEFZ            OT7EwBdXxAY<br>## 3 VVVkM3paU0NzSFMtN3NtbjJId2dNMEZBLjFMUV9XUjRSdW9F            1LQ_WR4RuoE<br>##   contentDetails.videoPublishedAt<br>## 1        2018-02-08T15:07:27.000Z<br>## 2        2018-02-09T05:14:26.000Z<br>## 3        2018-02-05T07:04:42.000Z</pre><p>It would only take one familiar with the package to interpret this output. For sake of easy identification, I have marked the video id.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*uIxKR5RIdzhkpXFi6RNTjA.jpeg" /></figure><p>In my next post, I will show how extracted data can be visualized through plots and how to make these statistical findings more meaningful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1419e9aefcc5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Experiences of coding a Twitter bot in R]]></title>
            <link>https://medium.com/@tumuhimbisemoses/experiences-of-coding-a-twitter-bot-in-r-2c0334cbf03b?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c0334cbf03b</guid>
            <category><![CDATA[twitter]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Wed, 31 Jan 2018 00:20:10 GMT</pubDate>
            <atom:updated>2018-01-31T00:22:41.045Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*Ddxv5vIwL6Uj3trPqjhs8w.jpeg" /><figcaption>Bot?</figcaption></figure><p>In searching for ways how to maximize data analysis capabilities in social media analytics offered by R particularly how to scrap data from Twitter, I stumbled upon a post on how to create a Twitter Bot in R by <a href="http://www.r-datacollection.com/blog/Programming-a-Twitter-bot/">Automated Data Collection</a> with R. Inquisitive to put this into action, I rolled my sleeves and delved into the challenge.</p><p>I crafted my Bot according to the author’s Bot which motivates PhD students to return to work by barking orders using mild insults.</p><p>In the same suit, I created three Microsoft Excel workbooks to act as database storage for phrases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/0*MXkg0BIDsVPhDvPc.jpg" /></figure><p>The first step was to install the XLConnect library that allows Excel worksheets support for R based script. This was followed by loading the MS Excel sheets and printing the stored phrases to ensure the XLConnect library functions.</p><p>The first bug I encounter reveals an output error of an unused argument within the XLConnect library (the unused argument being simply=T). After a few minutes, I realize it is typing error, instead of using the correct arguments simplify, I wrote simply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*mEtJctLX7O5dvY1Z.jpg" /></figure><p>After solving the typo error, the script is able to print out the phrases from our MS Excel sheets. The next step is to repeat the same procedure and print out words and insults from other MS Excel sheets. In essence, the Bot is a troll Bot aimed at tweeting trolling tweets which are somewhat insulting. We then combine our phrases to make clear sentences with help from the stringr package.</p><p>The next stage involves connecting to the Twitter API which proved to be the most challenging section of the script. All errors point to an error in my Oauth authentication setup.</p><p>Error!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*5Zdy9DKvmqAA6YqV.jpg" /></figure><p>Yet another error!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*qOSrzkUWdhgPAHAj.jpg" /></figure><p>Is there an end to this ??</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/0*4Lr02Kl5hadoLRys.jpg" /></figure><p>Error!! Error!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*hrBS8x4HWWB72Ulr.jpg" /></figure><p>After much deliberation, I had to make small changes to the code such as removing certain arguments and unnecessary parentheses as well additional packages such as XML and ROauth.</p><p>Finally the script was able to send a tweet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/0*5u8jPqmNSv_suFGO.jpg" /></figure><p>Take note of the comparisons below to observe the difference between the earlier and recent versions of the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*RK1QPnciWcDY5MMOCcTeIw.jpeg" /><figcaption>First version</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*KiyE0MUFYpxnytzoZDUkcw.jpeg" /><figcaption>Second version</figcaption></figure><p>This is the complete working code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c0334cbf03b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fighting and losing to my data demons]]></title>
            <link>https://medium.com/@tumuhimbisemoses/fighting-and-losing-to-my-data-demons-2ca2b3137f68?source=rss-763aa58379de------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ca2b3137f68</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tumuhimbise Moses]]></dc:creator>
            <pubDate>Tue, 23 Jan 2018 11:21:59 GMT</pubDate>
            <atom:updated>2018-01-23T11:21:59.042Z</atom:updated>
            <content:encoded><![CDATA[<p>As a self taught data scientist, I always seek personal projects to refine my proficiency and command of skills. It is on this backdrop that coinciding wit the #Y4PTUG Transport Hackathon second season announcement that I made the decision to participate.</p><p>My proposed innovation type was to develop a simulation model known as <em>panya</em>. This was to serve as a pedestrian solution aimed at using machine learning prediction capabailities to identify the best routes that could be used by commuters leaving or entering into the city center at particular times such as peak or off-peak hours.</p><p>The first step to solve this problem was to collect traffic data in terms of the volume of vehicle traffic along major roads. I had earlier done a similar <a href="https://snapshotofamuser.wordpress.com/2016/07/28/where-people-live-in-kampala-according-to-the-old-taxi-park/">project</a> which used visual mapping and user experience information to identify where most people in Kampala lived according to the distribution and placement of stages in the old taxi park.</p><p>However, for this outstanding hurdle, I needed data to support my model. User experience alone as a seasoned commuter was not going to make sense to a data driven approach. My method was to source data on the volume of traffic in terms of the predicted number of cars on each road combined with actual average numbers and average time spent in traffic jam. I would then use precedence listing functions within the model to present the user with the most favorable route to use.</p><p>All of this is to be based on prediction supported by actual data of course.</p><p>Congested roads in Kampala are more prone to accidents especially at the hands of boda bodas in their attempts of disregarding traffic law to ease their maneuverability in traffic jam. Therefore, by creating a predictive machine learning model using statistical data, I hope to make sense of my proposed project.</p><p>My idea is not new, one such project is a locally developed app known as Traffica available on Google Playstore. It harnesses crowd sourcing to provide updates to commuters on traffic jam “choke points” and recommending alternative routes. To an average user, a more on-site account of a traffic jam makes more sense than a data drive model whose predictions may not be based on real-time situations and dynamic unforeseeable events such as flooding caused by unpredictable weather.</p><p>Herein lays the challenge. As machine learning and artificial intelligence systems take center stage in day to day life. Is there a way to overcome the acute utilization of data to solve some of our community’s problems in Uganda?</p><p>Look out for my next post as a attempt to overcome a seemingly impossible task of using data to solve a common problem.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ca2b3137f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>