<?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 Kenny Evans on Medium]]></title>
        <description><![CDATA[Stories by Kenny Evans on Medium]]></description>
        <link>https://medium.com/@newtonsspawn?source=rss-ac315aed546c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fKs51zcPqW0U7F6BU5cacg.png</url>
            <title>Stories by Kenny Evans on Medium</title>
            <link>https://medium.com/@newtonsspawn?source=rss-ac315aed546c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:51:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@newtonsspawn/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[Identifying Natural Disasters in Real Time Via Social Media]]></title>
            <link>https://medium.com/@newtonsspawn/identifying-natural-disasters-in-real-time-via-social-media-c629b6637604?source=rss-ac315aed546c------2</link>
            <guid isPermaLink="false">https://medium.com/p/c629b6637604</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[semantic-analysis]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[natural-disasters]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kenny Evans]]></dc:creator>
            <pubDate>Fri, 17 May 2019 18:25:36 GMT</pubDate>
            <atom:updated>2019-05-17T18:25:36.790Z</atom:updated>
            <content:encoded><![CDATA[<h3>Problem Statement</h3><p>With increasing levels of climate change, disasters have been happening more and more frequently over the years. However, government response times have not been able to keep parity, as evidenced by how areas were handled in the wake of Hurricanes Katrina and Maria, affecting Louisiana and Puerto Rico respectively. While official sources like USGS are still useful resources for informing the people regarding natural disasters, social media may be able to offer its’ own unique value of information. As a result, we want to harness the power and influence of social media, in our case Twitter, to effectively and efficiently alert people in the event of a natural disaster. Ultimately, our goal is to design and implement an app that will be able to alert users for all disaster events, as close to real time by utilizing Twitter activity to identify these events and notify people when an event first occurs.</p><h3>Data Acquisition</h3><p>We decided to focus on three types of disasters: hurricanes, earthquakes, and wildfires. Using the open-source GetOldTweets3, we then acquired data for Hurricane Harvey, Hurricane Irma, Hurricane Maria, the 2011 North Bay earthquake, the 2014 Prague, Oklahoma earthquake, the Carr fire, the Woolsey Fire, and the Camp Fire dating from a week predisaster to the disaster and from the disaster to a week postdisaster.</p><h3>Exploratory Data Analysis</h3><p>We were able to scrape 31423 predisaster tweets and 67127 postdisaster tweets. We used custom list of disaster related words to classify post disaster tweets as disaster related or not and automatically classified all of the predisaster tweets as nondisaster related. Of the postdisaster tweets, 22320 were disaster related. Thus, 33 percent of the postdisaster tweets were disaster related and 22.5 percent of the total tweets were disaster related.</p><p>Our initial attempts to analyze the wildfire data was complicated by the fact that there were shootings at the same time and roughly the same geographic location as the wildfires. To resolve this problem, we created a custom list of stopwords that would help us filter out any shooting related keywords, using word2vec to help us find similar words and phrases. However, once we removed any shooting related keywords, the accuracy of our models increased.</p><h3>Modelling</h3><p>We initially ran 3 models to analyze our text corpus: Latent Dirichlet Allocation, Principal Component Analysis, and Singular Value Decomposition.The naive model, or predicting the most dominant class 100 percent of the time, would give a correct result 77 percent of the time. Our results when we ran SVD were 0.99 train and 0.94 test. When we ran PCA it was 0.81 train and 0.81 test. When we ran LDA it was 0.77 train and 0.77 test. After some hyperparameter tuning and refinement of stopwords, we managed to improve PCA to 0.9 train and 0.9 test, and LDA to 0.8 train and 0.8 test. However, since SVD had the best test results, we to chose to use it as our production model. Additionally, we chose to use Random Forest to classify, as it would help us deal with the imbalance of our classes without upsampling or downsampling.</p><h3>Conclusion</h3><p>In conclusion, we believe that moving forward with Singular Value Decomposition and Random Forest classification is the correct way to go. Additionally, we should broaden our search terms to look for more types of disasters, and hire foreign language speakers so that we can search for disaster posts in non-English languages. If possible, we should also broaden to different social media platforms such as Weibo or Facebook in order to have better coverage. Care should also be taken to reinforce communications infrastructure such as landlines and cell towers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c629b6637604" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Semantic Analysis of Reddit Posts and Comments]]></title>
            <link>https://medium.com/@newtonsspawn/semantic-analysis-of-reddit-posts-and-comments-3a13caa67f6d?source=rss-ac315aed546c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a13caa67f6d</guid>
            <category><![CDATA[semantic-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[rugby]]></category>
            <dc:creator><![CDATA[Kenny Evans]]></dc:creator>
            <pubDate>Fri, 17 May 2019 18:13:15 GMT</pubDate>
            <atom:updated>2019-05-17T18:13:15.537Z</atom:updated>
            <content:encoded><![CDATA[<h3>Rugby Union (rugbyunion) vs. Rugby League (nrl)</h3><h3>Overview</h3><p>There are two main types of rugby, union and league. While extremely similar, each have different rules and sets of required skills to play. Players and fans alike very seldom partake in both forms, usually having a strong preference of one over the other. While social media provides many forums for fans of either type of rugby, there are many sites and pages dedicated to rugby itself, without any designation as to which type.</p><p>Marketers and advertisers of rugby union and rugby league have a huge interest in being able to identify which type of rugby any particular individual favors. Targeting such persons can provide a significant savings in advertising costs, and increase sales by ensuring their campaigns are getting to their most likely customers.</p><p>I intend to build a tool that will analyze the posts and comments of rugby fans on social media, and predict which type of rugby they enjoy the most. I will analyze Reddit posts and comments from the rugbyunion and nrl subreddits and use machine learning to identify which subreddit a given comment was pulled from.</p><h3>Modeling Steps</h3><h4>Data Collection</h4><p>To perform this analysis, I pulled 20,000 posts and comments each from the main rugby union subreddit, rugbyunion, and the main rugby league subreddit, url.</p><p>To avoid overly obvious identifiers such as professional player names and team names, I scraped the lists of current players and teams for each from Wikipedia pages and removed those words from the posts and comments.</p><p>Lastly, I removed the words ‘union’ and ‘league’, as well as any Reddit tags, websites, and other miscellaneous symbols and characters.</p><h4>Semantic and Exploratory Data Analysis</h4><p>Initial analyses did not provide much insight into the differences between the comments from each site. No specific words stood out as particularly favoring one or the other. In fact, it took over one thousand words to explain just 70% of the variance between the two sites.</p><p>Analysis of the average word and character counts per post for each site also did not provide much insight. Both union and league posters tend to comment with similar patterns and language-complexity.</p><p>My luck appeared to turn around once I ran the dataset through the models. I used two different models, logistic regression and random forest classifier, to analyze the posts and was able to predict the origin of the posts with a little over 77% accuracy. While not the best score in the world, it far exceeds the 50/50 chance of identifying it correctly without modeling.</p><p>The models allowed me to analyze what the most important words were in regards to classifying the origins of each post. While these words helped the machine learning algorithms detect their class with a modest level of accuracy, they do not provide us with any real insight into how posters of the different sites communicate and share information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZP2hgt1Oce0mxMEKdtsEtg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZPHzmUxU7cjxco3FkAbmJw.png" /></figure><h3>Model Selection and Results</h3><p>I used logistic regression and random forest classifier to yield my predictions. Logistic regression provided 70% accuracy on my test set while random forest provided over 77%. As such, I settled on random forest classifier for my production model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a13caa67f6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technical Report — Kaggle’s Freesound Audio Tagging Competition]]></title>
            <link>https://medium.com/@newtonsspawn/technical-report-kaggles-freesound-audio-tagging-competition-ff9eefa1568c?source=rss-ac315aed546c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff9eefa1568c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kenny Evans]]></dc:creator>
            <pubDate>Fri, 17 May 2019 14:00:13 GMT</pubDate>
            <atom:updated>2019-05-17T14:00:13.782Z</atom:updated>
            <content:encoded><![CDATA[<h3>Technical Report — Kaggle’s Freesound Audio Tagging Competition</h3><h3>Problem Statement</h3><p>Audio signal processing is a very complex field with many applications, ranging from automated voice detection (Siri) to music recognition (Shazam). Freesound has launched a competition, using the Kaggle platform, to build a model that can train on both clean and noisy sound samples to be able to predict and classify what new sounds it reads may be.</p><p>The challenge here will be figuring out how best to transform incoming audio signals and how best to model on those transformations to best make these predictions.</p><h3>Data Collection</h3><p>The data was collected directly from <a href="https://www.kaggle.com/c/freesound-audio-tagging-2019/data">Kaggle</a> using their API and downloaded to an AWS EFS instance. This EFS instance was mounted to a t2.micro AWS EC2 instance where all of the processing was completed.</p><h3>Exploratory Data Analysis</h3><p>The dataset contained three sets of sound files, broken into a curated set, a noisy set, and a sample set. Each of the sound files range from about a third of a second to thirty seconds in length.</p><p>The curated set contained 4,970 sound clips. The noisy set contained 19,815 sound clips. Each of these sets were labelled in an included file in .csv format. I chose not to deal with the sample set of files as these were not labelled and as such, were not helpful for my analysis.</p><p>The labels cover a broad array of different categories of sounds, including voices, knocking, typing, purring, barking, farting, rain, glass shattering, musical instruments, bells, etc. There are 80 types of sounds in total. The majority of the sounds are multi-labelled, and the noisy dataset includes background noises as well.</p><h3>Comparing Wave Signals</h3><p>To look at the wave files graphically, I used the <em>wave</em> library. This library allowed me to read in the signals’ amplitudes and enumerate them according to their frame rates for plotting purposes.</p><p>Here is an example of a fart sound from the curated set. It only includes the fart noise without any background noises and thus provides a clean signal to process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xLtoFANmqqJG2PYS.png" /></figure><p>The next two examples show different examples from the noisy set. As you can see, the background noise makes it very hard to isolate the signal and make any sense of the sound graphically. The first one is an example of a motorcycle and the second of a simple raindrop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wPxZvwR0K-t8bZaM.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0tLtVUO6vsoAZ_QW.png" /></figure><p>It is clear that just looking at the amplitudes of the wave signals for each of the sounds will not be enough to distinguish between similar sounds, especially those with background noise in the file.</p><h3>Other Sound-Related Parameters</h3><p>I also looked at the parameters of the wave files to get a sense of the types of information I could gain from each sample. All of the sounds have a single channel and a framerate of 44100. The number of frames vary based on the length of the file and none of them are compressed.</p><blockquote>code sample</blockquote><pre>f = wave.open(&#39;../data/train_curated/0019ef41.wav&#39;)<br>print(f.getparams())<br>f.close()</pre><blockquote>output</blockquote><pre>_wave_params(nchannels=1, sampwidth=2, framerate=44100, nframes=90616, comptype=&#39;NONE&#39;, compname=&#39;not compressed&#39;)</pre><p>Based on this information, I decided a more complex breakdown of the sound signals would be necessary to conduct any meaningful analysis.</p><h3>Pre-Processing</h3><h4>Sound Samples</h4><p>I processed the sounds samples for modeling using three different methods:</p><ol><li>amplitudes from the raw signals,</li><li>Fourier transformations to decompose the signals into their constituent frequencies, and</li><li>Mel-frequency cepstral coefficients (MFCCs).</li></ol><p>The first two methods did not offer much in help in terms of a strong variance between varying sound signals. Hence, I decided to pre-process my samples using MFCCs for modeling.</p><p>MFCCs are derived as follows (via <a href="https://en.wikipedia.org/wiki/Mel-frequency_cepstrum">Wikipedia</a>):</p><ol><li>Take the Fourier transform of (a windowed excerpt of) a signal.</li><li>Map the powers of the spectrum obtained above onto the mel scale, using triangular overlapping windows.</li><li>Take the logs of the powers at each of the mel frequencies.</li><li>Take the discrete cosine transform of the list of mel log powers, as if it were a signal.</li><li>The MFCCs are the amplitudes of the resulting spectrum.</li></ol><p>The MFCCs essentially represent the short-term power spectrum of the sound signal. The MFCCs for each sound sample showed a significant variance between samples and thus were better suited for modeling purposes.</p><p>To perform the transformations, I relied on the <em>librosa</em> library. I processed the entire dataset, curated and noisy, parsing each with 20, 40, and 60 MFCCs.</p><h4>Labels</h4><p>The labels were not initially given in a user-friendly format. They were given as a single column in the CSV file, with commas separating multi-labelled samples. I converted these labels to a sparse matrix, consisting of 80 columns of 0s and 1s, with multiple 1s representing multi-labelled sound files.</p><h3>Modeling</h3><p>I opted to use a Sequential Neural Network (SNN) to perform the modeling on the transformed sound files. I conducted all of the modeling on an t2.micro AWS EC2 instance with an EFS instance mounted to it.</p><h4>Strategy</h4><h4>Single-Labelled Modeling</h4><p>I conducted the first models with the labels in their original form, treating the comma-separated multi-labels as a single label. I removed samples without duplicate labels and ran them through an SNN to see how well they performed this way. Yes, this was cheating, as it was not returning individual sound predictions and instead just groups of sounds but I thought it was worth seeing the results.</p><p>After lots of trial and error and fine-tuning, this is the SNN that yielded the best results:</p><pre>model = Sequential()<br><br>model.add(Dense(256, activation=&#39;relu&#39;, input_shape=(60,)))<br><br>model.add(Dense(256, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(64, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(64, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(256, activation=&#39;relu&#39;,))<br><br>model.add(Dense(num_labels, activation=&#39;softmax&#39;))<br><br>model.compile(loss=&#39;categorical_crossentropy&#39;,<br>              metrics=[&#39;accuracy&#39;],<br>              optimizer=&#39;adam&#39;)</pre><p>I ran this SNN with all of my MFCC transformations, using 20, 40, and 60 MFCCs. The best performing transformation by far was the one with 40 MFCCs. Here are the graphs showing the accuracy and loss metrics over each training epoch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*a1WYOyw_Kp_BXtRa.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oTTWAsljFQ9f3voM.png" /></figure><p>The results were not bad! I got to about 22% accuracy before the model started overfitting. But remember, we are cheating here. I expected the model to perform much worse once we start using the multi-labelled sparse matrix.</p><h4>Multi-Labelled Modeling</h4><p>The next step was to conduct the modeling using the multi-labelled sparse matrix. I had to make a few changes to the SNN such as the activation function for the output layer and the associated loss function, as I’d be returning a a binary 1 or 0 for each label in the resulting matrix.</p><pre>model = Sequential()<br><br>model.add(Dense(256, activation=&#39;relu&#39;, input_shape=(40,)))<br><br>model.add(Dense(256, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(64, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(64, activation=&#39;relu&#39;,))<br>model.add(Dropout(0.5))<br><br>model.add(Dense(256, activation=&#39;relu&#39;,))<br><br>model.add(Dense(num_labels, activation=&#39;sigmoid&#39;))<br><br>model.compile(loss=&#39;sigmoid&#39;,<br>              metrics=[&#39;accuracy&#39;],<br>              optimizer=&#39;adam&#39;)</pre><p>This did not go well at all. The loss function could not measure the model’s performance correctly because with a sparse matrix containing 80 labels, there’d always be at least 78 true negatives (TNs), making it over 98% accurate even with a random guess. the resulting graphs so just how hard of a time the model had.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c7cRzLAAfgFlMG9x.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ATs-daVDeGrWN35M.png" /></figure><h4>Customized Multi-Labelled Modeling</h4><p>The next step was to customize the previous SNN to allow the model to train on each label independently, using accuracy for each, and using precision to determine its overall success instead of accuracy, since precision does not take into account TNs.</p><p>As this will be my production model for the time being, the results are discussed in the following ‘Results’ section.</p><h3>Results</h3><p>After all of the modeling with the various transformations, here is a summary of the useful metrics.</p><pre>| Model                 | Accuracy  | Precision |<br>| --------------------- | --------- | --------- |<br>| baseline              | .002      | .002      |<br>| SNN (single-labelled) | .224      | n/a       |<br>| SNN (multi-labelled)  | n/a       | .003      |<br>| SNN (custom)          | n/a       | .055      |</pre><p>While 5.5% precision is not a result worth bragging about, it is 27.5 times better than the baseline. This means we are at least moving in the right direction.</p><p>Finally, I wanted to see which sounds preformed the best in my custom multi-labelled model and which performed the worst.</p><p>The top 10 sounds my model was able to predict are in the plot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sI9BcrHPMF3fRjbM.png" /></figure><p>The worst 10 sounds my model was able to predict are in the plot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vUhlGyRrOH3JY9o_.png" /></figure><p>The top and worst performing sounds seem to make sense. The best performing are very distinct sounds while the worst performing have many competing sounds that are very similar in nature, such as determining the difference between a woman’s and a child’s voice.</p><h3>Future Steps</h3><ol><li>Improve Loss Function — There is reason to believe that a better performing loss function will result in the model performing better on each successive run.</li><li>Different Transformations — There are many more ways to transform sounds and conduct signal processing. We could apply different techniques here and even combine different types to see if they perform better in our models.</li><li>Background Noise Reducer — Because the model has a hard time separating the sounds from the background noise in the noisy samples, developing a method to subtract the background noise from each file would serve to help isolate the target sounds better.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff9eefa1568c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>