<?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 Elias Andualem on Medium]]></title>
        <description><![CDATA[Stories by Elias Andualem on Medium]]></description>
        <link>https://medium.com/@eandualem?source=rss-bb712ce953c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IoFWLTEV9iCpxf0Tcf16vA.jpeg</url>
            <title>Stories by Elias Andualem on Medium</title>
            <link>https://medium.com/@eandualem?source=rss-bb712ce953c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 11:10:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eandualem/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[Causal Inference]]></title>
            <link>https://levelup.gitconnected.com/causal-inference-3d45b98ed6ae?source=rss-bb712ce953c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d45b98ed6ae</guid>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[data-exploration]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[causality]]></category>
            <category><![CDATA[bayesian-machine-learning]]></category>
            <dc:creator><![CDATA[Elias Andualem]]></dc:creator>
            <pubDate>Mon, 30 Aug 2021 05:02:16 GMT</pubDate>
            <atom:updated>2021-08-31T22:18:22.959Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KO2mgrap7ddSvaTEp2x9AA.png" /><figcaption>Image by <a href="https://pixabay.com/users/gustavorezende-1488336/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=6076266">Gustavo Rezende</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=6076266">Pixabay</a></figcaption></figure><p>Imagine that you create a new gaming app. Uninstall rates are very high despite the application taking up a small space and being very responsive. You want to reduce Uninstall rates of the app. To meet this objective, you start by comparing users who have uninstalled the application with those who haven’t.</p><p>Results show that there is a correlation between progress in the game and uninstalls. Does this mean helping people progress through the game; perhaps by lowering the difficulty, uninstall rate will decrease? Not necessarily. It could be the case, e.g. users who like the game can play more frequently, allowing them to advance. The reduced difficulty may reduce those users’ engagement. ​The result doesn’t necessarily indicate a direct correlation here; just some users progress through the game, and these users happen to keep their application.</p><p>Causal inference is a technique by which we determine if the causal explanation is accurate; in scenarios like those outlined above. It works by controlling confounding factors. It gives us a better understanding of the causes and impacts so that we can make better decisions.</p><p>In this post, I’ll use Breast Cancer Wisconsin (Diagnostic) data available on Kaggle.</p><h3>GitHub Link</h3><p><a href="https://github.com/10-Academy-quad-squad/casual-graph">GitHub - 10-Academy-quad-squad/casual-graph</a></p><h3>Data</h3><p>The dataset contains 569 samples of malignant and benign tumor cells. The first two columns of the dataset store the unique ID numbers of the samples and the corresponding diagnosis (M=malignant, B=benign), respectively.</p><p>Columns 3–32 contain 30 real-valued features that have been computed from digitized images of a fine needle aspirate (FNA) of a breast mass. These features describe characteristics of the cell nuclei present in the image and can be used to build a model to predict whether a tumor is benign or malignant.</p><p>These 30 features are derived from the following ten real-valued features that are computed for each cell nucleus.</p><ul><li>radius (mean of distances from center to points on the perimeter)</li><li>texture (standard deviation of gray-scale values)</li><li>perimeter</li><li>area</li><li>smoothness (local variation in radius lengths)</li><li>compactness (perimeter² / area — 1.0)</li><li>concavity (severity of concave portions of the contour)</li><li>concave points (number of concave portions of the contour)</li><li>symmetry</li><li>fractal dimension (“coastline approximation” — 1)</li></ul><h3>Dataset Exploration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*hVPaV0IxqbvhuDLFITj8IA.png" /></figure><p>Of the 569 findings, 357 (or 62.7%) have been labeled malignant, and the remaining 212 (or 37.3%) have been labeled benign.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZvxxeAdY0hIfo5FCXE2Tw.jpeg" /></figure><p>The figure shows the correlation between our input features with diagnosis. Now let’s create a distribution in increasing order of their correlation with diagnosis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5eG8GeLrR9bQB13XrZ4Cow.png" /></figure><p>We can observe features that have a higher correlation with the diagnosis have a distribution graph for Malignant and Benign that is very different. Whereas features with low correlation have distribution graph for Malignant and Benign that is similar. It shows they are not contributing factors in diagnosis. Here we will use the top 9 features with a higher correlation with diagnosis.</p><h3>CausalNex</h3><blockquote>CausalNex is a Python library that allows data scientists and domain experts to co-develop models that go beyond correlation and consider causal relationships. ‘CausalNex’ provides a practical ‘what if’ library which is deployed to test scenarios using Bayesian Networks.</blockquote><p>Here we will use CausalNex to co-develop models that go beyond correlation and consider causal relationships. For an in-depth explanation of functionalities provided by CausalNex and a demonstration of their usage, I would recommend these two posts.</p><ul><li><a href="https://causalnex.readthedocs.io/en/latest/03_tutorial/03_tutorial.html">A first CausalNex tutorial - causalnex 0.10.0 documentation</a></li><li><a href="https://ljubica-vujovic.medium.com/causalnex-in-action-finding-the-why-behind-the-scenes-c50b78abc888">CausalNex in Action — Finding the WHY behind the scenes</a></li></ul><h3>Learning Structure from Data</h3><p>The CausalNex library focuses on using directional acyclic graphs (DAGs), which are useful data structures. Now let’s start by building a causal structural model using CausalNex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*Fa7j9Jhb-4M8d8hVyHOcsg.png" /></figure><p>The graph has too many connections, and we cannot infer much from that. Let’s decrease the number of edges by applying Edge pruning. Edge pruning allows us to remove edges with weight below the defined threshold. Simplifying the graphs improves the visualization of a network and can be used to extract the main structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*rz5a40ds31isj7OaPMYNdA.png" /></figure><p>The simplified graph shows that six features directly affect the diagnosis.</p><h3>Stability of Causal Graph</h3><p>The stability of the graph shows whether the correlation we found between the features is present in reality. In a stable graph, the correlation between features will not change substantially when the data size changes. We will use Jaccard Similarity Index for computing similarity between graphs.</p><blockquote>The Jaccard similarity index (sometimes called the Jaccard similarity <em>coefficient</em>) compares members for two sets to see which members are shared and which are distinct. It’s a measure of similarity for the two sets of data, with a range from 0% to 100%. The higher the percentage, the more similar the two populations.</blockquote><pre>def jaccard_similarity(g, h):<br>    i = set(g).intersection(h)<br>    <em>return</em> round(len(i) / (len(g) + len(h) - len(i)), 3)</pre><p>Casual graph With 50% of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*7mVfr8xVzq2QsdHeo1BT4g.png" /></figure><p>Casual graph With 60% of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*Jtfyj-VeOr9bWv6I73hWPg.png" /></figure><p>The Jaccard similarity between the casual graph of 60% and 70% of the data is 86.7%.</p><p>Casual graph With 70% of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*vg4X30NUjEUpE-b-EyuNNg.png" /></figure><p>The Jaccard similarity between the casual graph of 60% and 70% of the data is 85.7%. We have managed to get the Jaccard similarity index is greater than 80% by increasing the data by 10%, which shows our graph is stable.</p><h3>Bayesian Network</h3><blockquote>A Bayesian network is a compact, flexible and interpretable representation of a joint probability distribution. It is also an useful tool in knowledge discovery as directed acyclic graphs allow representing causal relations between variables.</blockquote><p>Bayesian networks consist of two parts: a structure and parameters. The structure is a directed acyclic graph (DAG) that expresses conditional independencies and dependencies among random variables associated with nodes. The parameters consist of conditional probability distributions associated with each node.</p><p>CausalNex provides the BayesianNetwork implementation that we are going to use. But before that, we need to reduce the graph to its Markov Blanket and discretize numeric features.</p><h3>Reducing a graph to its Markov Blanket</h3><p>Now, assume that the target is our variable of interest. We do not need all the nodes in the network, but only the Markov blanket of the target.</p><blockquote>The Markov blanket (MB) of a variable is the subset of nodes in the Bayesian Network that contain all the useful information for predicting that variable. In other words, nodes outside a variable’s MB will (given knowledge of the nodes in the MB) do not influence the variable of interest.</blockquote><p>The concept is particularly useful when we have a large graph and a variable of interest. Instead of considering the whole graph, we need only to consider the Markov blanket subgraph to make a more efficient inference.</p><pre>bn = BayesianNetwork(sm)<br>blanket = get_markov_blanket(bn, &#39;diagnosis&#39;)<br>edge_list = list(blanket.structure.edges)<br>edge_list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*iZnzM-Pbg6p8ifQ399xobg.png" /></figure><h3>Discretising Numeric Features</h3><p>CausalNex provides the BayesianNetwork implementation that we are going to use. But the BayesianNetwork implementation expects all its features to be discrete values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eACwuKNvT_GEweTMGo5Uvg.png" /></figure><p>As we can see, all of the features in our dataset are continuous and cannot be fit to the Bayesian Network as they are. Assume that we are trying to predict the target given other features, we can discretize other features using a supervised learning approach.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1350b86b82b8f8de5005874decf0749a/href">https://medium.com/media/1350b86b82b8f8de5005874decf0749a/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V5pcJ9X6tMp_ICR3HEo-CA.png" /></figure><p>After applying the discretization to our data, all continuous feature values got mapped to 8 unique values.</p><h3><strong>Train</strong></h3><p>Finally, we will fit conditional probabilities using the discrete features. Then we calculate the recall, precision, f1, and accuracy using the test data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3f9916b0ac1339d4318e14adfab455d/href">https://medium.com/media/c3f9916b0ac1339d4318e14adfab455d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40daa6d8b88e97004de37f34b744473f/href">https://medium.com/media/40daa6d8b88e97004de37f34b744473f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2HJ8kx7dpjSBJepgS1Dc0Q.png" /></figure><h3><strong>Conclusion</strong></h3><p>To compare, we trained a Logistic Regression model with the entire dataset and features, and the outcome is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3p_uBMfrC4VWTkvEutQhEw.png" /></figure><p>The result shows Logistic Regression has better accuracy. Even though Logistic performed better than Bayesian Network, Bayesian Network gives us the capacity to ask more questions and comprehend and quantify better causation in the data.</p><p>[1]: Ljubica Vujovic: CausalNex in Action — Finding the WHY Behind the Scenes. <a href="https://ljubica-vujovic.medium.com/causalnex-in-action-finding-the-why-behind-the-scenes-c50b78abc888">https://towardsdatascience.com/sales-forecasting-from-time-series-to-deep-learning-5d115514bfac</a>.</p><p>[2]: Greg Ainslie-Malik: Causal Inference: Determining Influence in Messy Data. <a href="https://www.splunk.com/en_us/blog/platform/causal-inference-determining-influence-in-messy-data.html">https://www.splunk.com/en_us/blog/platform/causal-inference-determining-influence-in-messy-data.html</a>.</p><p>[3]: Lina Faik: How can Machine Learning algorithms include better Causality? <a href="https://towardsdatascience.com/how-can-machine-learning-algorithms-include-better-causality-e869ca60e54d">https://towardsdatascience.com/how-can-machine-learning-algorithms-include-better-causality-e869ca60e54d</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d45b98ed6ae" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/causal-inference-3d45b98ed6ae">Causal Inference</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End-to-end Speech Recognition model for Amharic using TensorFlow]]></title>
            <link>https://medium.com/analytics-vidhya/end-to-end-speech-recognition-model-for-amharic-using-tensorflow-e72e60775bd9?source=rss-bb712ce953c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e72e60775bd9</guid>
            <category><![CDATA[speech-recognition]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[amharic]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Elias Andualem]]></dc:creator>
            <pubDate>Sat, 14 Aug 2021 12:41:47 GMT</pubDate>
            <atom:updated>2021-08-16T05:00:14.319Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKk8RJtGbgk6oydDzft26g.png" /></figure><p>Deep Learning has changed the game when it comes to voice recognition by introducing end-to-end models. These models take in an audio signal and directly output transcriptions. In this blog, we will build an end-to-end automatic speech recognition pipeline for Amharic. Our completed pipeline will accept raw audio as input and return a predicted transcription of the spoken language.</p><p>Amharic is an Ethiopian Semitic language, which is a subgroup within the Semitic branch of the Afroasiatic languages. According to Wikipedia, the language has 32,000,000 Native speakers and 25,000,000 L2 speakers. This figure may not be exact. I am just putting it here for context.</p><h3>GitHub Link</h3><p><a href="https://github.com/10acad-group3/speech_recognition">GitHub - 10acad-group3/speech_recognition</a></p><h3>Data</h3><p>In this project, the <a href="https://github.com/getalp/ALFFA_PUBLIC">ALFFA_PUBLIC</a> dataset is used for the training and validation of the model. Data contains approximately 11k audio clips totaling around 18 hours of speech in Amharic. Each audio clip lasts a few seconds and comes with its transcription.</p><p>Data Features</p><ul><li>Input features (X): audio clips of spoken words</li><li>Target labels (y): a text transcript of what was spoken</li></ul><h3>Preprocessing</h3><p>Data is one of the most important aspects of speech recognition. Data preprocessing plays a vital role in developing an effective automatic speech recognition system.</p><p>The dataset contains audio files in “. wav” format with a sampling rate of 16 kHz. For most basic speech recognition systems, 8kHz is sufficient. As a result, I have started by resampling the audio signals at 8kHz. Then I have prepared metadata containing the name of the audio file, corresponding transcription, char length of each transcription, and the audio length in seconds. Here is an overview of the metadata.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MCE3gI502PTEnowM7unwPA.png" /></figure><h4><strong>Mean Normalization</strong></h4><p>Normalizing will reduce undesirable noise in our signal and give us a clean audio file. The picture shows the before and after sample audio files from the training set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OdmJdMAk4IGeYI5Oib5Aaw.png" /></figure><h4><strong>Splitting</strong></h4><p>We will use Libros for removing the silence in the audio signals. Libros split function returns a NumPy array containing non-silent intervals in the audio signal. The function does not return any audio, just the start, and end points of the non-silent slices in the audio. By concatenating the non-silent segments, We can decrease the silence in each audio signal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hl6j-iD0i-T2EfzAGNePDQ.png" /></figure><h4>Outliers</h4><p>Outliers are extreme values that deviate from other observations on data, they may indicate variability in measurement, experimental errors, or a novelty. In other words, an outlier is an observation that diverges from an overall pattern on a sample. In our dataset, we will be looking for outliers based on duration, character length, and speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*920_mIhb0XEnRO3rcU1zTA.png" /></figure><p>We can see most of the audios are between 4 to 8 seconds long. I have removed the audio shorter than 2 seconds and longer than 14 seconds. This has resulted in a loss of around 2% of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShOrZOHa-40bV8iXsnOUqQ.png" /></figure><p>Most transcripts range in length from 30 to 70 characters. This includes rows without transcription and others with more than 150 characters long transcription. After deleting rows in which transcription length is less than 10 and more than 125, data loss was less than 1%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gl7C1VNdCGkYbAecNo63OQ.png" /></figure><p>I have tried to estimate the audio speed by dividing the character length by duration. We can do this because we have already removed most of the extra silence of the audio signals. The distribution graph above shows there are rows where the speed is zero and more than 16. I have removed the rows where the speed is less than four or more than twelve. This also led to the loss of approximately 2% of the data.</p><h3>Data Augmentation</h3><p>Next, we can do data augmentation on the raw audio signal by changing the Pitch or Audio Speed and adding noise by a random amount. Data augmentation adds more variety to our input data and helps the model to generalize on a wider range of inputs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fc608b5196318cf9878d3908bf997ae/href">https://medium.com/media/9fc608b5196318cf9878d3908bf997ae/href</a></iframe><h3>Features</h3><p>The key to any machine learning method is extracting features from data. Features represent data and serve as input to the model. Here we will use Mel Spectrograms to derive features from the audio signal.</p><p>The spectrogram is a 2D plot between time and frequency where each point in the plot represents the amplitude of a particular frequency at a particular time in terms of intensity of color. In simple terms, the spectrogram is a spectrum (broad range of colors) of frequencies as it varies with time.</p><p>A Mel Spectrogram makes two important changes relative to a regular Spectrogram that plots Frequency vs Time. It uses the Mel Scale instead of Frequency on the y-axis and It uses the Decibel Scale instead of Amplitude to indicate colors.</p><p>There is an article on How to Easily Process Audio on Your GPU with TensorFlow by David Schwertfeger. The article describes how to leverage the power of the GPU to process audio data using the TensorFlow signal processor. You can read more on the details of how to generate Mel Spectrogram form audio signal from the blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxX3YDNCZiIibyLCGR2PIg.png" /></figure><h3>Data Generator</h3><p>Now that we have completed all the pre-processing steps, we will define a Custom data generation Class using Keras.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea1c1f460191768f96f9ea4a7be10723/href">https://medium.com/media/ea1c1f460191768f96f9ea4a7be10723/href</a></iframe><p>Rather than resizing all the audio samples to have the same length by padding them with silence. The class will pad the audio and transcription based on the longest in the batch. Since padding can affect the way the networks function and can make a great deal when it comes to the performance and accuracies of our model. Sorting our data based on duration and generating each bach with small padding will allow us to minimize the downside of padding.</p><p>The class returns three augmented versions for a single audio file. Since we are augmenting the audio every time rather than saving the augmented file, our data will change randomly for every batch. For instance, the speed of the audio can speed up or slow down randomly. This will considerably increase the variability in our input data.</p><h3>CTC</h3><p>We will use the CTC loss as the base loss function for our model. CTC is used to align the input and output sequences when the input is continuous and the output is discrete, and there are no clear element boundaries that can be used to map the input to the elements of the output sequence.</p><p>The Keras CTC loss function expects y_true, y_pred, input_length, and label_length as an argument. The problem is the input length changes for each batch in our data. We can compute the input length, by dividing the length of the audio by hop size.</p><p>The other point is if we are using Convolutional or Max Pooling layers in our model, we need to recompute input length since they can reduce the dimensions of the feature maps.</p><p>The final point to keep in mind is the input length (number of time slices) should be greater than two times transcription length plus One. This is mentioned in the CTC paper. Apart from these points, we can calculate CTC loss just by following the documentation from Keras.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f72838ffa5bc06741cdadc94088cf5a/href">https://medium.com/media/3f72838ffa5bc06741cdadc94088cf5a/href</a></iframe><h3>Model</h3><p>I will be using a similar model to the Deep Speech 2 architecture. The model will have two main neural network modules. Three layers of Residual Convolutional Neural Networks to learn the relevant audio features. Then a set of Bidirectional Recurrent Neural Networks to leverage the learned audio features. Let’s look into the implementation of the model using Keras.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a48d8170dd37c924fa12e7b9403a7406/href">https://medium.com/media/a48d8170dd37c924fa12e7b9403a7406/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*oD6VUPiA7sVccBIG0okYYw.png" /></figure><p>This visualization shows the performance of the model over a period of time. The training took about 8 hours using only one GPU. I have continued training the model, but the validation loss didn’t improve much. One thing to keep in mind while looking at this is the loss is calculated not just for the clean data but for the augmented versions as well.</p><h3>Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9BEBpWVawNWgGFmKEeKJA.png" /></figure><p>We can see the model performs well on short sentences</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGBbLIeZ6bt77K0x-xL4lQ.png" /></figure><p>The word error rate is higher for longer sentences. Nevertheless, the result is promising, since we have only trained the model on 18 hours of data.</p><p>[1]: David Schwertfeger: How to Easily Process Audio on Your GPU with TensorFlow. <a href="https://towardsdatascience.com/how-to-easily-process-audio-on-your-gpu-with-tensorflow-2d9d91360f06">https://towardsdatascience.com/how-to-easily-process-audio-on-your-gpu-with-tensorflow-2d9d91360f06</a></p><p>[2]: Derrick Mwiti: A 2019 Guide for Automatic Speech Recognition. <a href="https://heartbeat.fritz.ai/a-2019-guide-for-automatic-speech-recognition-f1e1129a141c">https://heartbeat.fritz.ai/a-2019-guide-for-automatic-speech-recognition-f1e1129a141c</a></p><p>[3]: Derrick Mwiti: A 2019 Guide for Automatic Speech Recognition. <a href="https://heartbeat.fritz.ai/a-2019-guide-for-automatic-speech-recognition-f1e1129a141c">https://heartbeat.fritz.ai/a-2019-guide-for-automatic-speech-recognition-f1e1129a141c</a></p><p>[4]: Michael Nguyen: Building an end-to-end Speech Recognition model in PyTorch. <a href="https://www.assemblyai.com/blog/end-to-end-speech-recognition-pytorch">https://www.assemblyai.com/blog/end-to-end-speech-recognition-pytorch</a></p><p>[5]: Ketan<strong> </strong>Doshi: Audio Deep Learning Made Simple. <a href="https://towardsdatascience.com/audio-deep-learning-made-simple-automatic-speech-recognition-asr-how-it-works-716cfce4c706">https://towardsdatascience.com/audio-deep-learning-made-simple-automatic-speech-recognition-asr-how-it-works-716cfce4c706</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e72e60775bd9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/end-to-end-speech-recognition-model-for-amharic-using-tensorflow-e72e60775bd9">End-to-end Speech Recognition model for Amharic using TensorFlow</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Twitter Data to explore the Impact of Covid-19 in Africa]]></title>
            <link>https://medium.com/analytics-vidhya/using-twitter-data-to-explore-the-impact-of-covid-19-in-africa-bdb8d3adf346?source=rss-bb712ce953c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdb8d3adf346</guid>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[topic-modeling]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-preprocessing]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Elias Andualem]]></dc:creator>
            <pubDate>Wed, 30 Jun 2021 17:12:48 GMT</pubDate>
            <atom:updated>2021-07-12T06:46:50.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vi7SS09LOS5ag47CdMFkWg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@muthengimbuvi?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">muthengi mbuvi</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Beginning from December 2019, the whole world is confronting an infectious disease called coronavirus. With restrictions on movement and stay-at-home orders in place, social media platforms such as Twitter have become the only means for users to keep in touch with one another and an outlet to express their concerns, opinions, and feelings about the pandemic. During these challenging times, people have used Twitter to appreciate frontline health workers and uplift each other through difficult times. On the other hand, Twitter has also been a place for massive misinformation and negative Tweets, creating unnecessary anxiety towards this disease.</p><p>In this article, I chose to explore the impact of COVID19 on people’s livelihoods via a dashboard using Twitter data. The system we build will provide an insight into the impact COVID19 had on people’s livelihoods. The system will aid in understanding people’s knowledge, attitude, and perceptions towards COVID 19. It will give an insight into some of the common misconceptions people have towards covid19, thereby aiding efforts made in combating the disease, like the effective distribution of vaccines.</p><p>At the end of this article, we will set up a system using Twitter data. The data is collected using keywords `covide19` and `Africa`. There will be a fully automated MLOps pipeline that analyses Twitter application data, using sentiments of the tweets and the topic discussed in tweets. And finally, we will deploy a dashboard that will allow us to explore the findings using Streamlit.</p><h3>GitHub Link</h3><p><a href="https://github.com/eandualem/Twitter-Data-Analysis">eandualem/Twitter-Data-Analysis</a></p><h3>Data Extraction</h3><p>As discussed, we will use data collected from Twitter using keywords `covide19` and `Africa`. The data is in a JSON format and contains 6532 rows. We start by extracting pandas dataframe from the JSON file. A <strong>DataFrame</strong> is two-dimensional size-mutable, potentially heterogeneous tabular data structure with labeled axes (rows and columns).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24c53f8731d02ecab8127fa6f12b71c1/href">https://medium.com/media/24c53f8731d02ecab8127fa6f12b71c1/href</a></iframe><p>The function read_json reads JSON file and returns a list of JSON which contains individual tweets. The class TweetDfExtractor parses tweets JSON into a pandas data frame. Here I have extracted 15 columns from the tweeter data. Once the columns are extracted, we create a zip containing the 15 columns. Then we generate a data frame using pandas and save it to a file named ‘processed_tweet_data.csv’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WxzRzdypuCuHKKo6pDYwKA.png" /><figcaption>Data extracted from json</figcaption></figure><h3>Method</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u-SwE0GBTu9ChRi1NJwUjg.png" /><figcaption>System Design</figcaption></figure><p>Now we have the data in a pandas data frame. We can talk about the overall system. For this project, we will be following MLOps level 1, which is ML pipeline automation. MLOps is an engineering discipline that aims to unify ML systems development(dev) and ML systems deployment(ops) to standardize and streamline the continuous delivery of high-performing models in production¹.</p><p>The architecture will allow for Rapid experimentation, and the model is automatically trained in production using new data based on live pipeline triggers using Travis.</p><h3>Data Preprocessing</h3><p>Before exploration or creating a model, we need to preprocess the data. Remove unwanted columns or extract specific data from some columns, clean the original_text column, which contains the actual tweet text, and finally convert all the columns to the correct data type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/485cd0290c2ef3eee79d50d60a8c8940/href">https://medium.com/media/485cd0290c2ef3eee79d50d60a8c8940/href</a></iframe><p>Here is the list of things to do for preprocessing using Clean_Tweets class.</p><ul><li>Read processed_tweet_data.csv file using pandas.</li></ul><pre>tweets = pd.read_csv(&quot;../processed_tweet_data.csv&quot;)</pre><ul><li>If there are any duplicates in the data frame, we will drop them.</li></ul><pre>ct = Clean_Tweets()<br>tweets = ct.drop_duplicate(tweets)</pre><ul><li>Removing non-English tweets and drop the lang column. After dropping non-English tweets, we no longer need a lang column.</li></ul><pre>tweets = ct.remove_non_english_tweets(tweets)<br>tweets.drop([&#39;lang&#39;], axis=1, inplace=True)</pre><ul><li>Remove links, Punctuations, Numbers, and Special Characters from the original_text column.</li></ul><pre>tweets = ct.remove_links(tweets)<br>tweets = ct.remove_special_characters(tweets)</pre><ul><li>There are two types of hashtags in the dataset. Those that are in the hashtag column and those mentioned inside the original_text. We will clean both and output the theme in separate columns.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33937da7d8675b7199f1c84911b035d3/href">https://medium.com/media/33937da7d8675b7199f1c84911b035d3/href</a></iframe><ul><li>We extract screen names from the user_mantiodsns column and devices from the source column.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b70178ef13edbb22c4d3e610a1b3b0a7/href">https://medium.com/media/b70178ef13edbb22c4d3e610a1b3b0a7/href</a></iframe><ul><li>Turn all columns containing text to lower case.</li></ul><pre>tweets = ct.to_lower(tweets)</pre><ul><li>Convert all the columns to correct data type</li></ul><pre>tweets = ct.convert_to_string(tweets)<br>tweets = ct.convert_to_numbers(tweets)<br>tweets = ct.convert_to_boolean(tweets)<br>tweets = ct.convert_to_numbers(tweets)</pre><ul><li>Fill in the missing values</li></ul><pre>tweets[&quot;possibly_sensitive&quot;].fillna(False, inplace=True) tweets[&quot;place&quot;].fillna(&quot; &quot;, inplace=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7gkrtwhjIlShAaBDeSCuQ.png" /><figcaption>Dataframe after cleaning</figcaption></figure><p>All the steps above are explained in detail with data exploration and visualization in a <a href="https://github.com/eandualem/Twitter-Data-Analysis/blob/main/notebooks/preprocessing.ipynb">preprocessing.ipynb</a> notebook. We finish this section by saving the final data frame to clean_tweets.csv.</p><h3>Data Exploration and Visualization</h3><p>Now let us try to get a bit of insight into the data. For example, who is the top tweet author, how many tweets on average were made by a single person, most frequently mentioned words in a tweet, top Twitter hashtags used, the polarity (“positivity”, “negativity”, “neutrality”) ratio.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8XVwIRGXXlQRl4Jz5yaHxQ.png" /></figure><p>As we can see, the mean for the original author is 1.24, which means most of the tweets are from unique individuals except for one outlier who made 530 tweets out of the total 5248. This is problematic because we don’t want one person’s opinion to influence our models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ie5XJNLBSz9aVwjGl9fR6g.png" /><figcaption>Tweets polarity against their popularity.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ch4PHIAvPMX0zNe8jBvMUQ.png" /><figcaption>Tweets subjectivity against their popularity.</figcaption></figure><p>We can see positive tweets have the most retweet, favorites, followers, and friends count. Objective tweets have the most favorites, followers, and friends count. Objective tweets have the most retweet count. We don’t have very subjective tweets in the dataset, which will be one of our problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iR_BXne11aNI45Ga4thJ5w.png" /><figcaption>Tweets polarity against original author.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VU_E3qz4EJKz2jTwr_Lng.png" /><figcaption>Tweets polarity against the device from which they are made.</figcaption></figure><p>The above two plots show the count of original authors and the count of devices from which the tweets are made. We can see from the device name vaccine finder we are getting above 500 tweets which are all negative. This means half of the negative tweets are coming from this device. If you remember, we already found an outlier in a number of tweets made. That single user whose name is `puneupdater` is using this device. This means one person had made almost half of the negative tweets, 530 from 1277.</p><p>This a big flow in the data. The good thing is our system will automatically retrain when there is a change in the data. The system will be able to retrain and serve the new model. I have made more Exploration and Visualization in the <a href="https://github.com/eandualem/Twitter-Data-Analysis/blob/main/notebooks/preprocessing.ipynb">preprocessing.ipynb</a> notebook.</p><h3>Topic modelling</h3><p>Topic modeling is an unsupervised machine learning technique that’s capable of scanning a set of documents, detecting word and phrase patterns within them, and automatically clustering word groups and similar expressions that best characterize a set of documents².</p><p>We starting from topic modeling because it doesn’t require a predefined list of tags. That means we are not training data that’s been previously classified by humans.</p><pre>df = pd.DataFrame(columns=[&#39;clean_text&#39;])<br>df[&#39;clean_text&#39;] = tweets[&#39;original_text&#39;]</pre><p>We have already done most of the preprocessing steps. Here we will continue by removing stop words.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VkuFQuHzQLqbwL3yNtLg8w.png" /><figcaption>Top 10 words in the document</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/125f0933e7599390d4b5934b6fa16d2c/href">https://medium.com/media/125f0933e7599390d4b5934b6fa16d2c/href</a></iframe><p>This image shows the top 10 words in the document. As we can see most of them are stop words. We remove them because they don’t impact the semantics of a text, and doing so often (but not always) improves the performance of a model.</p><pre>sentence_list = [sent for sent in df[&#39;clean_text&#39;]] <br>word_list = [sent for sent in sentence_list]</pre><p>Now the next step is tokenization. <strong>Tokenization</strong> is a way of separating a piece of text into smaller units called tokens. Here, tokens can be either word, characters, or subwords. Here we tokenize the tweets into words.</p><pre>lemmatizer = WordNetLemmatizer()<br>word_list_lematized = []<br>for w in word_list:<br>  word_list_lematized.append([lemmatizer.lemmatize(x) for x in w])</pre><p>Then we do Lemmatisation which is a process of grouping together the inflected forms of a word. Lemmatization allows us to analyze these words as a single item, identified by the word’s lemma.</p><p>There two main topic modeling methods. <em>Latent Semantic Analysis (LSA) and Latent Dirichlet Allocation (LDA). Both are based on</em> the same underlying assumptions: the distributional hypothesis, (i.e. similar topics make use of similar words) and the statistical mixture hypothesis (i.e. documents talk about several topics) for which a statistical distribution can be determined. If you want an in-depth explanation on this topic there is a good blog on <a href="https://monkeylearn.com/blog/introduction-to-topic-modeling/">Topic Modeling</a> by Federico Pascual.</p><p>Here we will use LDA for mapping each tweet in our corpus, to a set of topics that covers a good deal of the words in the tweet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8749acc2495ab941454850c06ce10ba1/href">https://medium.com/media/8749acc2495ab941454850c06ce10ba1/href</a></iframe><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JrGHIrJuUFh_GkjDX7UVvA.png" /><figcaption>Visualization of topic modelling performed through LDA</figcaption></figure><h3>Sentiment Analysis</h3><pre><strong># Import the libraries</strong><br>import tweepy<br>from textblob import TextBlob<br>from wordcloud import WordCloud<br>import pandas as pd<br>import numpy as np<br>import re<br>import matplotlib.pyplot as plt<br>plt.style.use(&#39;fivethirtyeight&#39;)</pre><p><strong><em>“Sentiment analysis</em></strong><em>: the process of computationally identifying and categorizing opinions expressed in a piece of text, especially in order to determine whether the writer’s attitude towards a particular topic, product, etc. is positive, negative, or neutral.” — Oxford English Dictionary</em></p><p>We are going to build a model that can analyze our preprocessed tweets and be able to judge the sentiments behind the tweets.</p><pre>df = pd.DataFrame(columns=[&#39;clean_text&#39;, &#39;polarity&#39;])<br>df[&#39;clean_text&#39;] = tweets[&#39;original_text&#39;]<br>df[&#39;polarity&#39;] = tweets[&#39;polarity&#39;]</pre><p>We start by creating a new data frame containing columns clean-text and polarity.</p><pre>def text_category(p):<br>  if p &gt; 0:<br>    return &quot;positive&quot;<br>  elif p &lt; 0:<br>    return &quot;negative&quot;<br>  else:<br>    return &quot;neutral&quot;</pre><pre>df[&quot;polarity&quot;] = df[&quot;polarity&quot;].apply(text_category)<br>df = df[df[&#39;polarity&#39;] != &#39;neutral&#39;]</pre><p>Here we converted the polarity from float to categorical data using the text_category function. Then we have dropped tweets with neutral polarity. This will allow us to create a model that will just classify the tweets as positive or negative.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c769fec908458e437e05a232d0a993a/href">https://medium.com/media/6c769fec908458e437e05a232d0a993a/href</a></iframe><p>Here we start by Constructing a column named scoremap. It maps positive polarities to 1 and negative polarities to 0. Then we separated the input data (cleaned_text) and output data (score_map) as (X, y). Finally, after splitting the data into training data and validation data, we train the model using the function train_and_showscore.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8760a10d551fac662cef6baf25995e39/href">https://medium.com/media/8760a10d551fac662cef6baf25995e39/href</a></iframe><p><strong>Results: </strong>The training accuracy is 1.0 and, the validation accuracy is 0.96. It indicates the model is overfitting. This is to be expected given the flows we found in the data in the data exploration section.</p><h3>Streamlit</h3><p><a href="https://streamlit.io/">Streamlit</a> is an open-source Python library that makes it easy to create and share beautiful, custom web apps for machine learning and data science. Here we finalize our work by building a web app using Streamlit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/292ea152ae7034ae99f40e3d54215b43/href">https://medium.com/media/292ea152ae7034ae99f40e3d54215b43/href</a></iframe><p>Here is the schema to create a table that stores our Pandas data frame. There are classes for storing clean_data.csv in MySQL database and creating a Streamlight web app inside the folder <a href="https://github.com/eandualem/Twitter-Data-Analysis/tree/main/mysql%20and%20streamit">mysql_and_streamit</a>. Here are some pages from the web app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UwhesXiQNRXGnu4M_qjcGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U55TiL0EuYGNZIZBIjRVsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jVCG8d5F3d1KKmrak4e5yA.png" /></figure><p>[1]: google. MLOps: Continuous delivery and automation pipelines in machine learning. <a href="https://cloud.google.com/architecture/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning">https://cloud.google.com/architecture/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning</a>.</p><p>[2]: Federico Pascual (September 26th, 2019).Topic Modeling: An Introduction. <a href="https://monkeylearn.com/blog/introduction-to-topic-modeling/">https://monkeylearn.com/blog/introduction-to-topic-modeling/</a>.</p><p>[3]: Harshit Tyagi.What is MLOps — Everything You Must Know to Get Started. <a href="https://towardsdatascience.com/what-is-mlops-everything-you-must-know-to-get-started-523f2d0b8bd8">https://towardsdatascience.com/what-is-mlops-everything-you-must-know-to-get-started-523f2d0b8bd8</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdb8d3adf346" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/using-twitter-data-to-explore-the-impact-of-covid-19-in-africa-bdb8d3adf346">Using Twitter Data to explore the Impact of Covid-19 in Africa</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>