<?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 Mohammad Sharique on Medium]]></title>
        <description><![CDATA[Stories by Mohammad Sharique on Medium]]></description>
        <link>https://medium.com/@mohammadsharique?source=rss-746d5e27c5e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RB9lcNzKkGWxR6qy.</url>
            <title>Stories by Mohammad Sharique on Medium</title>
            <link>https://medium.com/@mohammadsharique?source=rss-746d5e27c5e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 17:03:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohammadsharique/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[A Natural Language Approach to Sentiment Analysis of tweets by labellinhg sentiment of tweets by…]]></title>
            <link>https://medium.com/@mohammadsharique/a-natural-language-approach-to-sentiment-analysis-of-tweets-by-labellinhg-sentiment-of-tweets-by-ea6af89441b1?source=rss-746d5e27c5e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea6af89441b1</guid>
            <dc:creator><![CDATA[Mohammad Sharique]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 16:37:33 GMT</pubDate>
            <atom:updated>2021-12-23T16:37:33.486Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Natural Language Approach to Sentiment Analysis of tweets by labellinhg sentiment of tweets by maximum frequency words by their authors.</h3><p>“Man’s sentimental attachment to objects is one of the life’s greatest consolations” — Orhan Pamuk</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YemKLm0kWGYI6CB_nUoMcA.jpeg" /><figcaption>Source- <a href="https://openai.com/blog/unsupervised-sentiment-neuron/">https://openai.com/blog/unsupervised-sentiment-neuron/</a></figcaption></figure><p>In this tutorial we will give sentiment scores to maximum frequency words of a tweet and also analyze the authors sentiment. Interesting, of course.</p><p>Let’s begin:</p><p>First we need to input data or call through API using Twitter API tweepy. Although, I will be discussing both the methods to get input data yet I would encourage you to use the data I am providing. This tutorial will give best results to readers if carried out on a Jupyter notebook such as <a href="https://colab.research.google.com/">Google Colab.</a></p><p>If we have chosen Google Colab as recommended then we will start by loading the data from say , Google Drive?</p><pre>from google.colab import drive</pre><pre>import os</pre><pre>drive.mount(&#39;/content/drive&#39;)</pre><pre>os.chdir(&quot;/content/drive/My Drive/Colab Notebooks&quot;)</pre><pre>os.listdir()</pre><p>This will display all those things which are there in the /Colab Notebooks directory of Google Drive as shown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u5g9J1pVsjV9n49UcKwnGQ.png" /></figure><p>We need to take json input ‘tweets.json’ for this tutorial.</p><p>We need to import few libraries to get the json data as pandas dataframe,</p><pre>import pandas as pd</pre><pre>pdObj = pd.read_json(&#39;tweets.json&#39;, orient=&#39;index&#39;)</pre><p>We have json object which holds ‘tweets.json’ file.</p><p>Let’s see what we have it in here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7iOFbl4U7OZbYnpjQ8NmQ.png" /></figure><p>Let’s continue our journey till getting this as a dataframe object.</p><pre>import csv</pre><pre>csvData = pdObj.to_csv(“file.csv”,index=False)</pre><p>So, now we have<strong> file.csv</strong> file</p><pre>file1 = open(“file.csv”)</pre><pre>csvreader = csv.reader(file1)</pre><pre>header = next(csvreader)</pre><pre>print(header)</pre><pre>rows = []</pre><pre>for row in csvreader:</pre><pre>    rows.append(row)</pre><pre>print(rows)</pre><pre>file1.close()</pre><pre>df_clean = pd.read_csv(‘file.csv’,</pre><pre>lineterminator=’\n’)</pre><p>So, finally we have the data in pandas dataframe. The <strong>df_clean</strong> stores the tweets author and tweets text which we can observe by printing top 3 tweets using <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.head.html"><strong>head(3)</strong></a> command. Wanna see for yourself?</p><pre>df_clean.head(3)</pre><p>Which outputs something as -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rP6n5tKeHSCtfLaaqJuwPA.png" /></figure><p>Now importing some very important packages/libraries,</p><pre>import numpy as np</pre><pre>import pandas as pd</pre><pre>import seaborn as sns</pre><pre>import matplotlib.pyplot as plt</pre><pre>import os</pre><pre># NLP packages</pre><pre>import nltk</pre><pre>from nltk import word_tokenize</pre><pre>from sklearn.feature_extraction.text import CountVectorizer</pre><pre>from sklearn.feature_extraction.text import TfidfVectorizer</pre><pre>from collections import Counter</pre><pre>from wordcloud import WordCloud</pre><pre># Modeling packages</pre><pre>from sklearn.model_selection import train_test_split</pre><pre>from sklearn.linear_model import LogisticRegression</pre><pre>from sklearn.ensemble import RandomForestClassifier</pre><pre>from sklearn.metrics import accuracy_score</pre><pre>from sklearn.metrics import f1_score</pre><pre>from pylab import rcParams</pre><pre>import warnings</pre><pre>warnings.filterwarnings(&quot;ignore&quot;)</pre><pre>rcParams[&#39;figure.figsize&#39;] = 14, 6</pre><pre>plt.style.use(&#39;ggplot&#39;)</pre><p>We will be counting the frequency by length of words as follows:</p><pre>words_per_tweet =df_clean.tweet_text.apply(lambda x: len(x.split(&quot; &quot;)))</pre><p>Visualize:</p><pre>words_per_tweet.hist(bins = 100)</pre><pre>plt.xlabel(&#39;Tweet Length (words)&#39;)</pre><pre>plt.ylabel(&#39;Frequency&#39;)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbJicjQAuASo1IBk06dvBA.png" /></figure><p>Average and skewness of words per tweet:</p><pre>print(&#39;Average words:&#39;, words_per_tweet.mean())</pre><pre>print(&#39;Skewness:&#39;, words_per_tweet.skew())</pre><p>You will get an output as depicted:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Otfh2cX0KxcTfeJ_hg6bmA.png" /></figure><p>My most favourite part: WORDCLOUD</p><pre>word_cloud_text = ‘’.join(df_clean[‘tweet_text’])</pre><pre>wordcloud = WordCloud(max_font_size=100, # Maximum font size for the largest word</pre><pre>max_words=100, # The maximum number of words</pre><pre>background_color=”white”, # Background color for the word cloud image</pre><pre>scale = 10, # Scaling between computation and drawing</pre><pre>width=800, # Width of the canvas</pre><pre>height=400 # Height of the canvas</pre><pre>).generate(word_cloud_text)</pre><pre>plt.figure()</pre><pre>plt.imshow(wordcloud,</pre><pre>interpolation=”bilinear”) # to make the displayed image appear more smoothly</pre><pre>plt.axis(“off”)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*BjYzmpPPMJQN7wEsk58uow.png" /></figure><p>Now preprocessing the data, changing all text into lowercase as the first step:</p><pre>df_clean[‘tweet_text_new’] =df_clean[‘tweet_text’].str.lower()</pre><h3>Tokenization</h3><p>Tokenization is a way of separating a piece of text into smaller units called tokens. Here, tokens can be either words, characters, or subwords. Hence, tokenization can be broadly classified into 3 types — word, character, and subword (n-gram characters) tokenization. source:<a href="https://www.analyticsvidhya.com/blog/2020/05/what-is-tokenization-nlp/">https://www.analyticsvidhya.com/blog/2020/05/what-is-tokenization-nlp/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*hmDr_rlM_TgaIJjAxyiPKw.gif" /><figcaption><a href="https://cdn.analyticsvidhya.com/wp-content/uploads/2020/05/rnn.gif">https://cdn.analyticsvidhya.com/wp-content/uploads/2020/05/rnn.gif</a></figcaption></figure><pre>from nltk import word_tokenize</pre><pre>import nltk</pre><pre>nltk.download(‘punkt’)</pre><pre># Word tokenization example:</pre><pre>word_tokenize(“A bird in hand is worth two in the bush!”)</pre><p>[‘A’, ‘bird’, ‘in’, ‘hand’, ‘is’, ‘worth’, ‘two’, ‘in’, ’the’, ’bush’, ‘!’]</p><pre># For reviews not converted to lower case</pre><pre>token_lists = [word_tokenize(each) for each in df_clean[&#39;tweet_text&#39;]]</pre><pre>tokens = [item for sublist in token_lists for item in sublist]</pre><pre>print(&quot;Number of unique tokens then: &quot;,len(set(tokens)))</pre><pre># For reviews converted to lower case</pre><pre>token_lists_lower = [word_tokenize(each) for each in df_clean[&#39;tweet_text_new&#39;]]</pre><pre>tokens_lower = [item for sublist in token_lists_lower for item in sublist]</pre><pre>print(&quot;Number of unique tokens now: &quot;,len(set(tokens_lower)))</pre><p>As we can see what tokenization has bring to the plate by the output of above code:</p><pre>Number of unique tokens then: 98781</pre><pre>Number of unique tokens now: 89362</pre><p><strong>Removing</strong> special characters</p><pre>### Selecting non alpha numeric charactes that are not spaces</pre><pre>spl_chars = df_clean[&#39;tweet_text_new&#39;].apply(lambda review: [char for char in list(review) if not char.isalnum() and char != &#39; &#39;])</pre><pre>## Getting list of list into a single list</pre><pre>flat_list = [item for sublist in spl_chars for item in sublist]</pre><pre>## Unique special characters</pre><pre>set(flat_list)</pre><p>This will output all unique special characters in the dataset. If you are getting as output something as follows then we’re going good.</p><p>{‘\n’, ‘\r’, ‘!’, ‘“‘, ‘#’, ‘$’, ‘%’, ‘&amp;’, “‘“, ‘(‘, ‘)’, ‘*’, ‘+’, ‘,’, ‘-’, ‘.’, ‘/’, ‘:’, ‘;’, ‘=’, ‘?’, ‘@’, ‘[‘, ‘\\’, ‘]’, ‘^’, ‘_’, ‘`’, ‘{‘, ‘|’, ‘}’, ‘~’, ‘\x80’, ‘\x91’, ‘\x92’, ‘\x96’, ‘\xa0’, ‘¡’, ‘£’, ‘©’, ‘«’, ‘\xad’, ‘®’, ‘°’, ‘±’, ‘´’, ‘·’, ‘»’, ‘¿’, ‘×’, ‘̇’, ‘،’, ‘؟’, ‘ً’, ‘ُ’, ‘ِ’, ‘٪’, ‘ं’, ‘ा’, ‘ि’, ‘ी’, ‘ु’, ‘ू’, ‘ॅ’, ‘े’, ‘ै’, ‘ॉ’, ‘ो’, ‘्’, ‘।’, ‘ั’, ‘ิ’, ‘ี’, ‘ื’, ‘ู’, ‘็’, ‘่’, ‘้’, ‘์’, ‘\u2009’, ‘\u200a’, ‘\u200b’, ‘\u200c’, ‘\u200d’, ‘‐’, ‘‑’, ‘‒’, ‘–’, ‘ — ‘, ‘‘’, ‘’’, ‘“‘, ‘”’, ‘„’, ‘†’, ‘•’, ‘…’, ‘\u202f’, ‘※’, ‘‼’, ‘⁃’, ‘\u2060’, ‘\u2066’, ‘\u2069’, ‘€’, ‘₱’, ‘⃑’, ‘⃣’, ‘™’, ‘↑’, ‘→’, ‘↔’, ‘↺’, ‘⇣’, ‘−’, ‘≤’, ‘≥’, ‘⌛’, ‘⏩’, ‘⏪’, ‘⏯’, ‘⏰’, ‘⏱’, ‘⏳’, ‘▪’, ‘▶’, ‘▼’, ‘◀’, ‘◆’, ‘◇’, ‘◈’, ‘○’, ‘☀’, ‘★’, ‘☎’, ‘☑’, ‘☔’, ‘☕’, ‘☘’, ‘☝’, ‘☞’, ‘☠’, ‘☹’, ‘☺’, ‘♀’, ‘♂’, ‘♡’, ‘♥’, ‘♨’, ‘♪’, ‘♾’, ‘⚓’, ‘⚕’, ‘⚙’, ‘⚠’, ‘⚡’, ‘⚪’, ‘⚫’, ‘⚽’, ‘⚾’, ‘⛑’, ‘⛷’, ‘✅’, ‘✈’, ‘✋’, ‘✌’, ‘✍’, ‘✏’, ‘✔’, ‘✝’, ‘✧’, ‘✨’, ‘✳’, ‘❄’, ‘❓’, ‘❔’, ‘❕’, ‘❗’, ‘❣’, ‘❤’, ‘➕’, ‘➡’, ‘⠀’, ‘⤴’, ‘⤵’, ‘⬅’, ‘⬆’, ‘⬇’, ‘⭐’, ‘\u3000’, ‘、’, ‘。’, ‘《’, ‘》’, ‘「’, ‘」’, ‘『’, ‘』’, ‘【’, ‘】’, ‘〔’, ‘〕’, ‘〜’, ‘・’, ‘︎’, ‘️’, ‘！’, ‘＃’, ‘％’, ‘（’, ‘）’, ‘＋’, ‘，’, ‘－’, ‘．’, ‘／’, ‘：’, ‘＞’, ‘？’, ‘＠’, ‘［’, ‘］’, ‘｜’, ‘～’, ‘､’, ‘�’, ‘𝄞’, ‘🅰’, ‘🆑’, ‘🆓’, ‘🆕’, ‘🇦’, ‘🇧’, ‘🇨’, ‘🇩’, ‘🇪’, ‘🇫’, ‘🇬’, ‘🇭’, ‘🇮’, ‘🇯’, ‘🇱’, ‘🇲’, ‘🇳’, ‘🇴’, ‘🇵’, ‘🇷’, ‘🇸’, ‘🇹’, ‘🇺’, ‘🌄’, ‘🌇’, ‘🌊’, ‘🌍’, ‘🌎’, ‘🌏’, ‘🌐’, ‘🌑’, ‘🌔’, ‘🌝’, ‘🌞’, ‘🌟’, ‘🌳’, ‘🌹’, ‘🌻’, ‘🌾’, ‘🍀’, ‘🍃’, ‘🍔’, ‘🍞’, ‘🍰’, ‘🍴’, ‘🍺’, ‘🍾’, ‘🎀’, ‘🎂’, ‘🎃’, ‘🎄’, ‘🎅’, ‘🎆’, ‘🎈’, ‘🎉’, ‘🎊’, ‘🎓’, ‘🎗’, ‘🎙’, ‘🎞’, ‘🎢’, ‘🎤’, ‘🎥’, ‘🎦’, ‘🎧’, ‘🎨’, ‘🎩’, ‘🎬’, ‘🎭’, ‘🎯’, ‘🎵’, ‘🎶’, ‘🎼’, ‘🎾’, ‘🎿’, ‘🏀’, ‘🏁’, ‘🏃’, ‘🏅’, ‘🏆’, ‘🏈’, ‘🏉’, ‘🏊’, ‘🏋’, ‘🏌’, ‘🏐’, ‘🏒’, ‘🏔’, ‘🏘’, ‘🏠’, ‘🏡’, ‘🏢’, ‘🏥’, ‘🏪’, ‘🏸’, ‘🏹’, ‘🏻’, ‘🏼’, ‘🏽’, ‘🏾’, ‘🏿’, ‘🐉’, ‘🐋’, ‘🐍’, ‘🐏’, ‘🐒’, ‘🐕’, ‘🐖’, ‘🐘’, ‘🐙’, ‘🐛’, ‘🐝’, ‘🐥’, ‘🐧’, ‘🐪’, ‘🐭’, ‘🐴’, ‘🐷’, ‘🐸’, ‘🐻’, ‘🐾’, ‘👀’, ‘👁’, ‘👂’, ‘👆’, ‘👇’, ‘👈’, ‘👉’, ‘👊’, ‘👋’, ‘👌’, ‘👍’, ‘👎’, ‘👏’, ‘👐’, ‘👑’, ‘👒’, ‘👓’, ‘👖’, ‘👛’, ‘👜’, ‘👞’, ‘👟’, ‘👠’, ‘👡’, ‘👢’, ‘👧’, ‘👨’, ‘👩’, ‘👭’, ‘👯’, ‘👴’, ‘👵’, ‘👹’, ‘👺’, ‘👻’, ‘👽’, ‘👿’, ‘💀’, ‘💁’, ‘💃’, ‘💄’, ‘💆’, ‘💉’, ‘💊’, ‘💋’, ‘💍’, ‘💎’, ‘💔’, ‘💕’, ‘💖’, ‘💗’, ‘💘’, ‘💙’, ‘💚’, ‘💛’, ‘💜’, ‘💝’, ‘💞’, ‘💟’, ‘💡’, ‘💣’, ‘💤’, ‘💥’, ‘💨’, ‘💩’, ‘💪’, ‘💫’, ‘💬’, ‘💯’, ‘💰’, ‘💲’, ‘💳’, ‘💴’, ‘💸’, ‘💻’, ‘💼’, ‘📃’, ‘📄’, ‘📅’, ‘📆’, ‘📈’, ‘📉’, ‘📊’, ‘📋’, ‘📌’, ‘📍’, ‘📑’, ‘📕’, ‘📖’, ‘📗’, ‘📙’, ‘📚’, ‘📝’, ‘📢’, ‘📣’, ‘📧’, ‘📫’, ‘📰’, ‘📱’, ‘📲’, ‘📷’, ‘📸’, ‘📹’, ‘📺’, ‘📻’, ‘📽’, ‘📿’, ‘🔁’, ‘🔄’, ‘🔆’, ‘🔈’, ‘🔊’, ‘🔍’, ‘🔎’, ‘🔏’, ‘🔑’, ‘🔔’, ‘🔗’, ‘🔘’, ‘🔙’, ‘🔛’, ‘🔜’, ‘🔥’, ‘🔬’, ‘🔴’, ‘🔵’, ‘🔶’, ‘🔸’, ‘🔹’, ‘🔻’, ‘🔽’, ‘🕘’, ‘🕰’, ‘🖊’, ‘🖌’, ‘🖕’, ‘🖤’, ‘🖥’, ‘🗓’, ‘🗝’, ‘🗞’, ‘🗣’, ‘😀’, ‘😁’, ‘😂’, ‘😃’, ‘😄’, ‘😅’, ‘😆’, ‘😇’, ‘😈’, ‘😉’, ‘😊’, ‘😋’, ‘😌’, ‘😍’, ‘😎’, ‘😏’, ‘😐’, ‘😑’, ‘😒’, ‘😓’, ‘😔’, ‘😕’, ‘😖’, ‘😘’, ‘😙’, ‘😚’, ‘😜’, ‘😝’, ‘😞’, ‘😟’, ‘😡’, ‘😢’, ‘😤’, ‘😥’, ‘😩’, ‘😫’, ‘😬’, ‘😭’, ‘😮’, ‘😰’, ‘😱’, ‘😲’, ‘😳’, ‘😴’, ‘😶’, ‘😷’, ‘😹’, ‘🙀’, ‘🙁’, ‘🙂’, ‘🙄’, ‘🙅’, ‘🙇’, ‘🙈’, ‘🙊’, ‘🙌’, ‘🙏’, ‘🚀’, ‘🚂’, ‘🚗’, ‘🚘’, ‘🚦’, ‘🚨’, ‘🚫’, ‘🚲’, ‘🚴’, ‘🛫’, ‘🛸’, ‘🛹’, ‘🤓’, ‘🤔’, ‘🤖’, ‘🤗’, ‘🤘’, ‘🤝’, ‘🤞’, ‘🤟’, ‘🤡’, ‘🤢’, ‘🤣’, ‘🤦’, ‘🤨’, ‘🤩’, ‘🤪’, ‘🤫’, ‘🤬’, ‘🤮’, ‘🤯’, ‘🤲’, ‘🤷’, ‘🤼’, ‘🥅’, ‘🥇’, ‘🥊’, ‘🥍’, ‘🥕’, ‘🥚’, ‘🥣’, ‘🥦’, ‘🥬’, ‘🥰’, ‘🥳’, ‘🥴’, ‘🥼’, ‘🦁’, ‘🦃’, ‘🦆’, ‘🦋’, ‘🦔’, ‘🦠’, ‘🧐’, ‘🧠’, ‘🧡’, ‘🧢’, ‘🧪’, ‘🧫’, ‘🧬’, ‘🧭’, ‘🧳’, ‘🧵’, ‘\U0001fa78’, ‘\U0001fa7a’, ‘\U0001fa81’, ‘\U000fe327’, ‘\U000fe4dd’, ‘\U000fe7d9’, ‘\U000fe826’, ‘\U000feb5e’, ‘\U000feb7b’, ‘\U000feb9f’}</p><p>Let’s do some preprocessing by backing up our tweets data.</p><pre>text_backup = df_clean[‘tweet_text_new’].copy()</pre><pre>df_clean[‘tweet_text_new’] = df_clean[‘tweet_text_new’].str.replace(r’[^A-Za-z0–9 ]+’, ‘ ‘)</pre><pre>text_backup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8WPioGB-vquJN14c5oE-nw.png" /><figcaption>Result of <strong>text_backup</strong></figcaption></figure><pre>print(&quot;- Old Review -&quot;)</pre><pre>print(text_backup.values[6])</pre><pre>print(&quot;\n- New Review -&quot;)</pre><pre>print(df_clean[&#39;tweet_text_new&#39;][6])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1A8LL-vOqym5ELBhu4zqA.png" /><figcaption>We will see something as this.</figcaption></figure><p>Same thing, but after removing special characters, let us see what changes we have brought,</p><pre>token_lists = [word_tokenize(each) for each in df_clean[&#39;tweet_text&#39;]]</pre><pre>tokens = [item for sublist in token_lists for item in sublist]</pre><pre>print(&quot;Number of unique tokens then: &quot;,len(set(tokens)))</pre><pre>token_lists = [word_tokenize(each) for each in df_clean[&#39;tweet_text_new&#39;]]</pre><pre>tokens = [item for sublist in token_lists for item in sublist]</pre><pre>print(&quot;Number of unique tokens now: &quot;,len(set(tokens)))</pre><p>Filter out the non worthwhile text(words) also called <a href="https://www.opinosis-analytics.com/knowledge-base/stop-words-explained/#.YcSb_S0w2u4"><strong>STOPWORDS</strong></a><strong>.</strong></p><figure><img alt="Stopword" src="https://cdn-images-1.medium.com/max/1024/1*dy25evXxRKszBDJaOsWy1Q.png" /></figure><p>Note we will be dealing with high/low frequency words also.</p><pre>from nltk.corpus import stopwords</pre><pre>import nltk</pre><pre>nltk.download(&#39;stopwords&#39;)</pre><pre>print(&#39;Available languages for NLTK v.3.4.5: &#39;)</pre><pre>print(stopwords.fileids())</pre><pre>noise_words = []</pre><pre>eng_stop_words = stopwords.words(‘english’)</pre><pre>eng_stop_words</pre><pre>stop_words = set(eng_stop_words)</pre><pre>without_stop_words = []</pre><pre>stopword = []</pre><pre>sentence = df_clean[‘tweet_text_new’][0]</pre><pre>words = nltk.word_tokenize(sentence)</pre><pre>for word in words:</pre><pre>    if word in stop_words:</pre><pre>         stopword.append(word)</pre><pre>    else:</pre><pre>         without_stop_words.append(word)</pre><pre>print(‘ — Original Sentence — \n’, sentence)</pre><pre>print(‘\n — Stopwords in the sentence — \n’, stopword)</pre><pre>print(‘\n — Non-stopwords in the sentence — \n’, without_stop_words)</pre><pre>def stopwords_removal(stop_words, sentence):</pre><pre>return [word for word in nltk.word_tokenize(sentence) if word not in stop_words]</pre><pre>df_clean[‘tweet_text_nonstop’] = df_clean[‘tweet_text_new’].apply(lambda row: stopwords_removal(stop_words, row))</pre><pre>df_clean[[‘tweet_text_new’,’tweet_text_nonstop’]]</pre><h3>By now we have clean data set to start working on -</h3><h3>Stemming &amp; lemmatization</h3><pre>from nltk.stem import PorterStemmer, LancasterStemmer # Common stemmers</pre><pre>from nltk.stem import WordNetLemmatizer # Common Lematizer</pre><pre>nltk.download(&#39;wordnet&#39;)</pre><pre>from nltk.corpus import wordnet</pre><pre>porter = PorterStemmer()</pre><pre>lancaster = LancasterStemmer()</pre><pre>lemmatizer = WordNetLemmatizer()<br>print(&quot;Lancaster Stemmer&quot;)</pre><pre>print(lancaster.stem(&quot;trouble&quot;))</pre><pre>print(lancaster.stem(&quot;troubling&quot;))</pre><pre>print(lancaster.stem(&quot;troubled&quot;))</pre><pre># Provide a word to be lemmatized</pre><pre>print(&quot;WordNet Lemmatizer&quot;)</pre><pre>print(lemmatizer.lemmatize(&quot;trouble&quot;, wordnet.NOUN))</pre><pre>print(lemmatizer.lemmatize(&quot;troubling&quot;, wordnet.VERB))</pre><pre>print(lemmatizer.lemmatize(&quot;troubled&quot;, wordnet.VERB))</pre><pre>def stemm_terms(row):</pre><pre>    return [lancaster.stem(term) for term in row]</pre><pre>def lemmatize_terms(row):</pre><pre>    return [lemmatizer.lemmatize(term) for term in row]</pre><pre>df_clean[&#39;tweet_text_stemm&#39;] = df_clean[&#39;tweet_text_nonstop&#39;].apply(lambda row: stemm_terms(row))</pre><pre>df_clean[&#39;tweet_text_lemm&#39;] = df_clean[&#39;tweet_text_nonstop&#39;].apply(lambda row: lemmatize_terms(row))</pre><pre>df_clean[[&#39;tweet_text_nonstop&#39;,&#39;tweet_text_stemm&#39;,&#39;tweet_text_lemm&#39;]]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6e5wDVaBoAUVGKZF0jCCFg.png" /><figcaption>\</figcaption></figure><p>If we want to get through to in-depth knowledge of stemming and lemmatisation, I would request to go through <a href="https://nlp.stanford.edu/IR-book/html/htmledition/stemming-and-lemmatization-1.html">https://nlp.stanford.edu/IR-book/html/htmledition/stemming-and-lemmatization-1.html</a>.</p><p>We are using sentiwordnet library from nltk(natural language toolkit):</p><pre>import nltk</pre><pre>nltk.download(‘sentiwordnet’)</pre><pre>from nltk.corpus import sentiwordnet as swn</pre><pre>words_tagged=[(‘Life’,’n’),(‘beautiful’,’a’)]</pre><pre>for word,tag in words_tagged:</pre><pre>concat=word+’.’+tag+’.01&#39;</pre><pre>print(swn.senti_synset(concat)) # labelling sentiment scores by words</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dOnk952ZRovHQ31OJToiEA.png" /></figure><pre>nltk.download(‘averaged_perceptron_tagger’)</pre><pre>nltk.download(‘universal_tagset’)</pre><pre>for i in range(len(df_clean.index)):</pre><pre>    text = df_clean.loc[i][‘tweet_text_new’]</pre><pre>    tokens = nltk.word_tokenize(text)</pre><pre>    tagged_sent = nltk.pos_tag(tokens)</pre><pre>    store_it = [(word, nltk.map_tag(‘en-ptb’, ‘universal’, tag)) for word, tag in tagged_sent]</pre><pre>def pos_senti(df_clean):#takes<br>    li_swn=[]<br>    li_swn_pos=[]<br>    li_swn_neg=[]<br>    missing_words=[]<br>    for i in range(len(df_clean.index)):<br>        text = df_clean.loc[i][&#39;tweet_text_new&#39;]<br>        tokens = nltk.word_tokenize(text)<br>        tagged_sent = pos_tag(tokens)<br>        store_it = [(word, map_tag(&#39;en-ptb&#39;, &#39;universal&#39;, tag)) for word, tag in tagged_sent]<br>        #print(&quot;Tagged Parts of Speech:&quot;,store_it)<br>        pos_total=0<br>        neg_total=0<br>        for word,tag in store_it:<br>            if(tag==&#39;NOUN&#39;):<br>                tag=&#39;n&#39;<br>            elif(tag==&#39;VERB&#39;):<br>                tag=&#39;v&#39;<br>            elif(tag==&#39;ADJ&#39;):<br>                tag=&#39;a&#39;<br>            elif(tag==&#39;ADV&#39;):<br>                tag = &#39;r&#39;<br>            else:<br>                tag=&#39;nothing&#39;<br>            <br>            if(tag!=&#39;nothing&#39;):<br>                concat = word+&#39;.&#39;+tag+&#39;.01&#39;<br>                try:<br>                  this_word_pos=swn.senti_synset(concat).pos_score()        this_word_neg=swn.senti_synset(concat).neg_score()</pre><pre>#print(word,tag,&#39;:&#39;,this_word_pos,this_word_neg)</pre><pre>except Exception as e:</pre><pre>wor = lem.lemmatize(word)</pre><pre>concat = wor+&#39;.&#39;+tag+&#39;.01&#39;</pre><pre># Checking if there&#39;s a possiblity of lemmatized word be accepted into SWN corpus</pre><pre>try:</pre><pre>    this_word_pos=swn.senti_synset(concat).pos_score()</pre><pre>    this_word_neg=swn.senti_synset(concat).neg_score()</pre><pre>except Exception as e:</pre><pre>wor = pstem.stem(word)</pre><pre>concat = wor+&#39;.&#39;+tag+&#39;.01&#39;</pre><pre># Checking if there&#39;s a possiblity of lemmatized word be accepted</pre><pre>try:</pre><pre>this_word_pos=swn.senti_synset(concat).pos_score()</pre><pre>this_word_neg=swn.senti_synset(concat).neg_score()</pre><pre>except:</pre><pre>missing_words.append(word)</pre><pre>continue</pre><pre>pos_total+=this_word_pos</pre><pre>neg_total+=this_word_neg</pre><pre>li_swn_pos.append(pos_total)</pre><pre>li_swn_neg.append(neg_total)</pre><pre>if(pos_total!=0 or neg_total!=0):</pre><pre>if(pos_total&gt;neg_total):</pre><pre>li_swn.append(1)</pre><pre>else:</pre><pre>li_swn.append(-1)</pre><pre>else:</pre><pre>li_swn.append(0)</pre><pre>df_clean.insert(5,&quot;pos_score&quot;,li_swn_pos,True)</pre><pre>df_clean.insert(6,&quot;neg_score&quot;,li_swn_neg,True)</pre><pre>df_clean.insert(7,&quot;sent_score&quot;,li_swn,True)</pre><pre>return df_clean</pre><pre>from textblob import TextBlob</pre><pre>count_total=0</pre><pre>count_pos1=0</pre><pre>count_pos2=0</pre><pre>count_neg1=0</pre><pre>count_neg2=0</pre><pre>count_neut=0</pre><pre>li_tb = []</pre><pre>for i in range(len(df_clean.index)):</pre><pre>sent = TextBlob(str(df_clean.loc[i][&#39;tweet_text_new&#39;]))</pre><pre>if(sent.sentiment.polarity&gt;=-2 and sent.sentiment.polarity&lt;-1):</pre><pre>count_neg2=count_neg2+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(-2)</pre><pre>elif(sent.sentiment.polarity&gt;=-1 and sent.sentiment.polarity&lt;0):</pre><pre>count_neg1=count_neg1+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(-1)</pre><pre>elif(sent.sentiment.polarity&gt;0 and sent.sentiment.polarity&lt;1):</pre><pre>count_pos1=count_pos1+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(1)</pre><pre>elif(sent.sentiment.polarity&gt;=1 and sent.sentiment.polarity&lt;2):</pre><pre>count_pos2=count_pos2+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(2)</pre><pre>else:</pre><pre>li_tb.append(0)</pre><pre>count_neut+=1</pre><pre>count_total=count_total+1</pre><pre>#         print(df.loc[i][&#39;full_text&#39;])</pre><pre>#         print(sent.sentiment)</pre><pre>print(&quot;Total tweets:&quot;,len(df_clean.index))</pre><pre>print(&quot;Total tweets with sentiment:&quot;,count_total)</pre><pre>print(&quot;positive(very) tweets:&quot;,count_pos2)</pre><pre>print(&quot;positive tweets:&quot;,count_pos1)</pre><pre>print(&quot;negative(very) tweets:&quot;,count_neg2)</pre><pre>print(&quot;negative tweets:&quot;,count_neg1)</pre><pre>print(&quot;neutral tweets:&quot;,count_neut)</pre><p>Now we have labelled data set</p><pre>from textblob import TextBlob</pre><pre>count_total=0</pre><pre>count_pos1=0</pre><pre>count_pos2=0</pre><pre>count_neg1=0</pre><pre>count_neg2=0</pre><pre>count_neut=0</pre><pre>li_tb = []</pre><pre>for i in range(len(df_clean.index)):</pre><pre>sent = TextBlob(str(df_clean.loc[i][&#39;tweet_text_new&#39;]))</pre><pre>if(sent.sentiment.polarity&gt;=-2 and sent.sentiment.polarity&lt;-1):</pre><pre>count_neg2=count_neg2+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(-2)</pre><pre>elif(sent.sentiment.polarity&gt;=-1 and sent.sentiment.polarity&lt;0):</pre><pre>count_neg1=count_neg1+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(-1)</pre><pre>elif(sent.sentiment.polarity&gt;0 and sent.sentiment.polarity&lt;1):</pre><pre>count_pos1=count_pos1+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(1)</pre><pre>elif(sent.sentiment.polarity&gt;=1 and sent.sentiment.polarity&lt;2):</pre><pre>count_pos2=count_pos2+1</pre><pre>count_total=count_total+1</pre><pre>li_tb.append(2)</pre><pre>else:</pre><pre>li_tb.append(0)</pre><pre>count_neut+=1</pre><pre>count_total=count_total+1</pre><pre>#         print(df.loc[i][&#39;full_text&#39;])</pre><pre>#         print(sent.sentiment)</pre><pre>print(&quot;Total tweets:&quot;,len(df_clean.index))</pre><pre>print(&quot;Total tweets with sentiment:&quot;,count_total)</pre><pre>print(&quot;positive(very) tweets:&quot;,count_pos2)</pre><pre>print(&quot;positive tweets:&quot;,count_pos1)</pre><pre>print(&quot;negative(very) tweets:&quot;,count_neg2)</pre><pre>print(&quot;negative tweets:&quot;,count_neg1)</pre><pre>print(&quot;neutral tweets:&quot;,count_neut)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DUlFOnZuwBxDyjb26nUUA.png" /></figure><pre>df_clean[“sent_score”]=li_tb<br>df_clean</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PauwwR3k6tDUBd0HZp7RWg.png" /></figure><pre>from nltk.corpus import stopwords</pre><pre>from nltk.stem import WordNetLemmatizer</pre><pre>from nltk.stem import PorterStemmer</pre><pre>pstem = PorterStemmer()</pre><pre>lem = WordNetLemmatizer()</pre><pre>stop_words = stopwords.words(‘english’)</pre><pre>for i in range(len(df_clean.index)):</pre><pre>text = df_clean.loc[i][‘tweet_text_new’]</pre><pre>tokens = nltk.word_tokenize(text)</pre><pre>tokens = [word for word in tokens if word not in stop_words]</pre><pre>for j in range(len(tokens)):</pre><pre>tokens[j] = lem.lemmatize(tokens[j])</pre><pre>tokens[j] = pstem.stem(tokens[j])</pre><pre>tokens_sent=’ ‘.join(tokens)</pre><pre>df_clean.at[i,”tweet_text_new”] = tokens_sent</pre><pre>df_clean</pre><pre>pos_text=list()</pre><pre>neg_text=list()</pre><pre>neut_text=list()</pre><pre>for i in range(len(df_clean.index)):</pre><pre>if(df_clean.loc[i][“sent_score”]&gt;0):</pre><pre>pos_text+=df_clean.loc[i][“tweet_text_new”]</pre><pre>elif(df_clean.loc[i][“sent_score”]&lt;0):</pre><pre>neg_text+=df_clean.loc[i][“tweet_text_new”]</pre><pre>else:</pre><pre>neut_text+=df_clean.loc[i][“tweet_text_new”]</pre><pre>list_text = [pos_text,neg_text,neut_text]</pre><pre>for txt in list_text:</pre><pre>word_cloud = WordCloud(width = 600,height = 600,max_font_size = 200).generate(txt)</pre><pre>plt.figure(figsize=(12,10))# create a new figure</pre><pre>plt.imshow(word_cloud,interpolation=”bilinear”)</pre><pre>plt.axis(“off”)</pre><pre>plt.show()</pre><pre>import sklearn</pre><pre>from sklearn.model_selection import train_test_split</pre><pre>SEED=4</pre><pre>x = df_clean.tweet_text_new</pre><pre>y = df_clean.sent_score</pre><pre>x_train,x_val_test,y_train,y_val_test = train_test_split(x,y,test_size=0.1,random_state=SEED)</pre><pre>x_val,x_test,y_val,y_test = train_test_split(x_val_test,y_val_test,test_size=0.5,random_state=SEED)</pre><pre>from sklearn.feature_extraction.text import CountVectorizer</pre><pre>cv=CountVectorizer(decode_error=&#39;ignore&#39;,lowercase=False,max_features=100)</pre><pre>x_traincv=cv.fit_transform(x_train.values.astype(&#39;U&#39;))</pre><pre>import numpy as np</pre><pre>from sklearn.feature_extraction.text import CountVectorizer</pre><pre>cv = CountVectorizer(decode_error=&#39;ignore&#39;,lowercase=False,max_features=1000)</pre><pre>#high_frequency words=cv.get_feature_names_out()</pre><pre>x_traincv=cv.fit_transform(x_train.values.astype(&#39;U&#39;))</pre><pre>top_sum=x_traincv.toarray().sum(axis=0)</pre><pre>top_sum_cv=[top_sum]#to let pandas know that these are rows</pre><pre>columns_cv = cv.get_feature_names()</pre><pre>high_frequency_words=columns_cv</pre><pre>x_traincvdf = pd.DataFrame(top_sum_cv,columns=columns_cv)</pre><pre>import operator</pre><pre>dic = {}</pre><pre>for i in range(len(top_sum_cv[0])):</pre><pre>dic[columns_cv[i]]=top_sum_cv[0][i]</pre><pre>sorted_dic=sorted(dic.items(),reverse=True,key=operator.itemgetter(1))</pre><pre>print(sorted_dic[1:])</pre><pre>bins = [w for w,v in sorted_dic][1:]#slicing to delete the first swachh bharat</pre><pre>freq = [v for w,v in sorted_dic][1:]</pre><pre>from matplotlib import pyplot as plt</pre><pre>plt.figure(figsize=(8,6))</pre><pre>plt.bar(bins,freq)</pre><pre>plt.xlabel(&#39;Words&#39;)</pre><pre>plt.xlabel(&#39;Words&#39;)</pre><pre>plt.ylabel(&#39;Frequency&#39;)</pre><pre>plt.title(&#39;Top words - Count Vectorizer&#39;)</pre><pre>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PWuXZdoIVBq2JUS04kAZNw.png" /></figure><pre>vect = CountVectorizer()</pre><pre>bow = vect.fit_transform(x_train.values.astype(‘U’))</pre><pre>total_features = len(vect.vocabulary_)</pre><pre>top_vect = CountVectorizer(max_features=int(total_features * 0.2))</pre><pre>top_bow = top_vect.fit_transform(x_train.values.astype(&#39;U&#39;))</pre><pre># Create a list of (term, frequency) tuples sorted by their frequency</pre><pre>sum_words = bow.sum(axis=0)</pre><pre>words_freq = [(word, sum_words[0, idx]) for word, idx in vect.vocabulary_.items()]</pre><pre>words_freq = sorted(words_freq, key = lambda x: x[1])</pre><pre># Keep only the terms in a list</pre><pre>vocabulary, _ = zip(*words_freq[:int(total_features * 0.2)])</pre><pre>vocabulary = list(vocabulary)</pre><pre>bottom_vect = CountVectorizer(vocabulary=vocabulary)</pre><pre>bottom_bow = bottom_vect.fit_transform(x_train.values.astype(&#39;U&#39;)top_sum=x_traincv.toarray().sum(axis=0)</pre><pre>top_sum_cv=[top_sum]#to let pandas know that these are rows</pre><pre>columns_cv = cv.get_feature_names()</pre><pre>high_frequency_words=columns_cv</pre><pre>x_traincvdf = pd.DataFrame(top_sum_cv,columns=columns_cv)</pre><pre>import operator</pre><pre>dic = {}</pre><pre>for i in range(len(top_sum_cv[0])):</pre><pre>dic[columns_cv[i]]=top_sum_cv[0][i]</pre><pre>sorted_dic=sorted(dic.items(),reverse=True,key=operator.itemgetter(1))</pre><pre>print(sorted_dic[1:])</pre><pre>bins = [w for w,v in sorted_dic][1:]#slicing to delete the first swachh bharat</pre><pre>freq = [v for w,v in sorted_dic][1:]</pre><pre>from matplotlib import pyplot as plt</pre><pre>plt.figure(figsize=(8,6))</pre><pre>plt.bar(bins,freq)</pre><pre>plt.xlabel(&#39;Words&#39;)</pre><pre>plt.xlabel(&#39;Words&#39;)</pre><pre>plt.ylabel(&#39;Frequency&#39;)</pre><pre>plt.title(&#39;Top words - Count Vectorizer&#39;)</pre><pre>plt.show()</pre><pre>import csv</pre><pre>header=[&#39;entity&#39;,&#39;frequency&#39;]</pre><pre>with open(&#39;dictionary.csv&#39;, &#39;w&#39;) as f:</pre><pre>write = csv.writer(f)</pre><pre>write.writerow(header)</pre><pre>for key in dic.keys():</pre><pre>f.write(&quot;%s,%s\n&quot;%(key,dic[key]))</pre><pre>f.close()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JkEmfViyqOh64_rtjFux1g.png" /></figure><pre>sent_dic={}</pre><pre>for dic[key] in df_clean.tweet_text_new:</pre><pre>if dic[key] in df_clean.tweet_text_new:</pre><pre>sent_dic[dic[key]].append(df_clean.sent_score)</pre><pre>continue<br>Header=[&#39;entity&#39;,&#39;author_name&#39;,&#39;overall_polarity&#39;]</pre><pre>with open(&#39;sentiment.csv&#39;, &#39;w&#39;) as f:</pre><pre>write = csv.writer(f)</pre><pre>write.writerow(Header)</pre><pre>print(sent_dic[sent_dic.keys()[i]])</pre><pre>for i in range(len(sent_dic.keys())):</pre><pre>if (sent_dic[sent_dic.keys()[i]]==-2):</pre><pre>write.writerow(sent_dic.keys()[i],df_clean[i],&#39;Very sad&#39;)</pre><pre>elif (sent_dic[sent_dic.keys()[i]]==-1):</pre><pre>write.writerow(sent_dic.keys()[i],df_clean[i],&#39;Sad&#39;)</pre><pre>elif (sent_dic[sent_dic.keys()[i]]==0):</pre><pre>write.writerow(sent_dic.keys()[i],df_clean[i],&#39;Neutral&#39;)</pre><pre>elif (sent_dic[sent_dic.keys()[i]]==-1):</pre><pre>write.writerow(sent_dic.keys()[i],df_clean[i],&#39;Happy&#39;)</pre><pre>else:</pre><pre>write.writerow(sent_dic.keys()[i],df_clean[i],&#39;Very happy&#39;)</pre><pre>f.close()</pre><p>By now we have (in our last block code) <strong>sentiment.csv</strong> saved in Google Colab directory ofGoogle Drive. We can see there that every tweet has sentiment labelled accordingly as we have wanted.</p><p>Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea6af89441b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Android apps using MVVM with Clean Architecture]]></title>
            <link>https://medium.com/@mohammadsharique/create-android-apps-using-mvvm-with-clean-architecture-ef47ca7b0795?source=rss-746d5e27c5e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef47ca7b0795</guid>
            <category><![CDATA[mvvm]]></category>
            <dc:creator><![CDATA[Mohammad Sharique]]></dc:creator>
            <pubDate>Mon, 06 Dec 2021 14:53:48 GMT</pubDate>
            <atom:updated>2021-12-06T14:53:48.115Z</atom:updated>
            <content:encoded><![CDATA[<p>The crux of the story is to undertand the benefits of maintaining <a href="https://www.freecodecamp.org/news/a-quick-introduction-to-clean-architecture-990c014448d2/">Clean Architecture</a> with respect to the growth of application codebase i.e., features and expansion of the team for that matter.</p><p>It’s an impeccable way of coding to use the best architecture as it prevents developers from getting into trouble during expansion of codebase and team. Therefore, we will discuss first some of the pros and cons and of course followed by its use cases and how we can follow its principles in our <a href="https://en.wikipedia.org/wiki/Android_(operating_system)">Android</a> application.</p><p>Why Architecture Is Important</p><p>All architectures have one common goal — to manage the complexity of your application. You may not need to worry about it on a smaller project, but it becomes a lifesaver on larger ones.</p><p>How does Clean Architecture approach the problem?</p><p>First we’ll see what it looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*3z8ArkV_C1nQ94TFzas_pQ.jpeg" /></figure><ul><li>The circles represent different levels of software in your app. There are two key things to note:</li><li>The center circle is the most abstract, and the outer circle is the most concrete. This is called the <strong>Abstraction Principle</strong>. The Abstraction Principle specifies that inner circles should contain business logic, and outer circles should contain implementation details.</li><li>Another principle of Clean Architecture is the <strong>Dependency Rule</strong>. This rule specifies that each circle can depend only on the nearest inward circle — this is what makes the architecture work.</li><li>The outer circle represents the concrete mechanisms that are specific to the platform such as networking and database access. Moving inward, each circle is more abstract and higher-level. The center circle is the most abstract and contains business logic, which doesn’t rely on the platform or the framework you’re using.</li></ul><p>Additional benefits of using an architecture when structuring app code include:</p><ul><li>Parts of the code get decoupled, and easier to reuse and test.</li><li>There’s a method to the madness. When someone else works on your code, they can learn the app’s architecture and will understand it better.</li></ul><h3>SOLID Principles</h3><p>Five design principles make software design more understandable, flexible and maintainable. Those principles are:</p><ul><li><strong>Single Responsibility</strong>: Each software component should have only one reason to change — one responsibility.</li><li><strong>Open-closed:</strong> You should be able to extend the behavior of a component, without breaking its usage, or modifying its extensions.</li><li><strong>Liskov Substitution:</strong> If you have a class of one type, and any subclasses of that class, you should be able to represent the base class usage with the subclass, without breaking the app.</li><li><strong>Interface Segregation:</strong> It’s better to have many smaller interfaces than a large one, to prevent the class from implementing the methods that it doesn’t need.</li><li><strong>Dependency Inversion:</strong> Components should depend on abstractions rather than concrete implementations. Also higher level modules shouldn’t depend on lower level modules.</li></ul><p>Cone view of Clean Architecture-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*46aWfF95ljXCjq-BgNJrvg.jpeg" /></figure><p>Source and credit: <a href="https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html">https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html</a> .<a href="https://www.codingblocks.net/podcast/clean-architecture-make-your-architecture-scream/">https://www.codingblocks.net/podcast/clean-architecture-make-your-architecture-scream/</a></p><p>Clean Architecture maximizes the use of these principles.</p><h3>Why to use MVVM with Clean Architecture?</h3><p>MVVM separates your view (i.e. Activitys and Fragments) from your business logic. MVVM is enough for small projects, but when your codebase becomes huge, your ViewModels start bloating. Separating responsibilities becomes hard.</p><p>MVVM with Clean Architecture is pretty good in such cases. It goes one step further in separating the responsibilities of your code base. It clearly abstracts the logic of the actions that can be performed in your app.</p><p>Note: You can combine Clean Architecture with the model-view-presenter (MVP) architecture as well. But since <a href="https://developer.android.com/topic/libraries/architecture/">Android Architecture Components</a> already provides a built-in ViewModel class, we are going with MVVM over MVP—no MVVM framework required!</p><h3>Advantages of Using Clean Architecture</h3><ul><li>Your code is even more easily testable than with plain MVVM.</li><li>Your code is further decoupled (the biggest advantage.)</li><li>The package structure is even easier to navigate.</li><li>The project is even easier to maintain.</li><li>Your team can add new features even more quickly.</li></ul><h3>Disadvantages of Clean Architecture</h3><ul><li>It has a slightly steep learning curve. How all the layers work together may take some time to understand, especially if you are coming from patterns like simple MVVM or MVP.</li><li>It adds a lot of extra classes, so it’s not ideal for low-complexity projects.</li></ul><h3>Use Cases</h3><ul><li>Represent your business actions: it’s what you can do with the application. Expect one use case for each business action</li><li>Pure business logic, plain code (except maybe some utils libraries)</li><li>The use case doesn’t know who triggered it and how the results are going to be presented (for example, could be on a web page, or — returned as JSON, or simply logged, and so on.)</li><li>Throws business exceptions</li></ul><p>Our data flow diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FxfaFWz8svQfTg49P7KM7w.png" /></figure><h3>Code example</h3><p>See the structure on <a href="https://github.com/Createdd/web-miner/tree/master/webminer">GitHub</a>.</p><h3>The Layers of MVVM with Clean Architecture</h3><p>The code is divided into three separate layers:</p><ol><li>Presentation Layer</li><li>Domain Layer</li><li>Data Layer</li></ol><p>We’ll get into more detail about each layer below. For now, our resulting package structure looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gHkXNhSWIXQbJbIP.png" /></figure><p>Even within the Android app architecture we’re using, there are many ways to structure your file/folder hierarchy. I like to group project files based on features. I find it neat and concise. You are free to choose whatever project structure suits you.</p><h3>The Presentation Layer</h3><p>This includes our Activitys, Fragments, and ViewModels. <strong>An </strong>Activity<strong> should be as dumb as possible. Never put your business logic in </strong>Activity<strong>s.</strong></p><p>An Activity will talk to a ViewModel and a ViewModel will talk to the domain layer to perform actions. A ViewModel never talks to the data layer directly.</p><p>Here we are passing a UseCaseHandler and two UseCases to our ViewModel. We’ll get into that in more detail soon, but in this architecture, a UseCase is an action that defines how a ViewModel interacts with the data layer.</p><p>Here’s how our <a href="https://www.toptal.com/software/kotlin-android-language">Kotlin code</a> looks:</p><pre><strong>class</strong> <strong>PostListViewModel</strong>(<br>        <strong>val</strong> useCaseHandler: UseCaseHandler,<br>        <strong>val</strong> getPosts: GetPosts,<br>        <strong>val</strong> savePost: SavePost): ViewModel() {<br></pre><pre>    <strong>fun</strong> <strong>getAllPosts</strong>(userId: <strong>Int</strong>, callback: <strong>PostDataSource</strong>.<strong>LoadPostsCallback</strong>) {<br>        <strong>val</strong> requestValue = GetPosts.RequestValues(userId)<br>        useCaseHandler.execute(getPosts, requestValue, <strong>object</strong> :<br>        UseCase.UseCaseCallback&lt;GetPosts.ResponseValue&gt; {<br>            <strong>override</strong> <strong>fun</strong> <strong>onSuccess</strong>(response: <strong>GetPosts</strong>.<strong>ResponseValue</strong>) {<br>                callback.onPostsLoaded(response.posts)<br>            }</pre><pre>            <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>                callback.onError(t)<br>            }<br>        })<br>    }</pre><pre>    <strong>fun</strong> <strong>savePost</strong>(post: <strong>Post</strong>, callback: <strong>PostDataSource</strong>.<strong>SaveTaskCallback</strong>) {<br>        <strong>val</strong> requestValues = SavePost.RequestValues(post)<br>        useCaseHandler.execute(savePost, requestValues, <strong>object</strong> :<br>        UseCase.UseCaseCallback&lt;SavePost.ResponseValue&gt; {<br>            <strong>override</strong> <strong>fun</strong> <strong>onSuccess</strong>(response: <strong>SavePost</strong>.<strong>ResponseValue</strong>) {<br>                callback.onSaveSuccess()<br>            }<br>            <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>                callback.onError(t)<br>            }<br>        })<br>    }</pre><pre>}</pre><h3>The Domain Layer</h3><p>The domain layer contains all the <strong>use cases</strong> of your application. In this example, we have UseCase, an abstract class. All our UseCases will extend this class.</p><pre><strong>abstract</strong> <strong>class</strong> <strong>UseCase</strong>&lt;<strong>Q : UseCase.RequestValues, P : UseCase.ResponseValue</strong>&gt; {</pre><pre>    <strong>var</strong> requestValues: Q? = null</pre><pre>    <strong>var</strong> useCaseCallback: UseCaseCallback&lt;P&gt;? = null</pre><pre>    <strong>internal</strong> <strong>fun</strong> <strong>run</strong>() {<br>        executeUseCase(requestValues)<br>    }</pre><pre>    <strong>protected</strong> <strong>abstract</strong> <strong>fun</strong> <strong>executeUseCase</strong>(requestValues: <strong>Q</strong>?)</pre><pre>    <em>/**<br>     * Data passed to a request.<br>     */</em><br>    <strong>interface</strong> <strong>RequestValues</strong></pre><pre>    <em>/**<br>     * Data received from a request.<br>     */</em><br>    <strong>interface</strong> <strong>ResponseValue</strong></pre><pre>    <strong>interface</strong> <strong>UseCaseCallback</strong>&lt;<strong>R</strong>&gt; {<br>        <strong>fun</strong> <strong>onSuccess</strong>(response: <strong>R</strong>)<br>        <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>)<br>    }<br>}</pre><p>And UseCaseHandler handles execution of a UseCase. We should never block the UI when we fetch data from the database or our remote server. This is the place where we decide to execute our UseCase on a background thread and receive the response on the main thread.</p><pre><strong>class</strong> <strong>UseCaseHandler</strong>(<strong>private</strong> <strong>val</strong> mUseCaseScheduler: UseCaseScheduler) {</pre><pre>    <strong>fun</strong> <strong>&lt;T : UseCase.RequestValues, R : UseCase.ResponseValue&gt;</strong> <strong>execute</strong>(<br>            useCase: <strong>UseCase</strong>&lt;<strong>T</strong>, R&gt;, values: <strong>T</strong>, callback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>R</strong>&gt;) {<br>        useCase.requestValues = values<br>        useCase.useCaseCallback = UiCallbackWrapper(callback, <strong>this</strong>)</pre><pre>        mUseCaseScheduler.execute(Runnable {<br>            useCase.run()<br>        })<br>    }</pre><pre>    <strong>private</strong> <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>notifyResponse</strong>(response: <strong>V</strong>,<br>                                                   useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;) {<br>        mUseCaseScheduler.notifyResponse(response, useCaseCallback)<br>    }</pre><pre>    <strong>private</strong> <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>notifyError</strong>(<br>            useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;, t: <strong>Throwable</strong>) {<br>        mUseCaseScheduler.onError(useCaseCallback, t)<br>    }</pre><pre>    <strong>private</strong> <strong>class</strong> <strong>UiCallbackWrapper</strong>&lt;<strong>V : UseCase.ResponseValue</strong>&gt;(<br>    <strong>private</strong> <strong>val</strong> mCallback: UseCase.UseCaseCallback&lt;V&gt;,<br>    <strong>private</strong> <strong>val</strong> mUseCaseHandler: UseCaseHandler) : UseCase.UseCaseCallback&lt;V&gt; {</pre><pre>        <strong>override</strong> <strong>fun</strong> <strong>onSuccess</strong>(response: <strong>V</strong>) {<br>            mUseCaseHandler.notifyResponse(response, mCallback)<br>        }</pre><pre>        <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>            mUseCaseHandler.notifyError(mCallback, t)<br>        }<br>    }</pre><pre>    <strong>companion</strong> <strong>object</strong> {</pre><pre>        <strong>private</strong> <strong>var</strong> INSTANCE: UseCaseHandler? = null<br>        <strong>fun</strong> <strong>getInstance</strong>(): UseCaseHandler {<br>            <strong>if</strong> (INSTANCE == null) {<br>                INSTANCE = UseCaseHandler(UseCaseThreadPoolScheduler())<br>            }<br>            <strong>return</strong> INSTANCE!!<br>        }<br>    }<br>}</pre><p>As its name implies, the GetPosts UseCase is responsible for getting all posts of a user.</p><pre><strong>class</strong> <strong>GetPosts</strong>(<strong>private</strong> <strong>val</strong> mDataSource: PostDataSource) :<br>UseCase&lt;GetPosts.RequestValues, GetPosts.ResponseValue&gt;() {</pre><pre>    <strong>protected</strong> <strong>override</strong> <strong>fun</strong> <strong>executeUseCase</strong>(requestValues: <strong>GetPosts</strong>.<strong>RequestValues</strong>?) {<br>        mDataSource.getPosts(requestValues?.userId ?: -1, <strong>object</strong> :<br>        PostDataSource.LoadPostsCallback {<br>            <strong>override</strong> <strong>fun</strong> <strong>onPostsLoaded</strong>(posts: <strong>List</strong>&lt;<strong>Post</strong>&gt;) {<br>                <strong>val</strong> responseValue = ResponseValue(posts)<br>                useCaseCallback?.onSuccess(responseValue)<br>            }<br>            <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>                <em>// Never use generic exceptions. Create proper exceptions. Since</em><br>                <em>// our use case is different we will go with generic throwable</em><br>                useCaseCallback?.onError(Throwable(&quot;Data not found&quot;))<br>            }<br>        })<br>    }<br>    <strong>class</strong> <strong>RequestValues</strong>(<strong>val</strong> userId: Int) : UseCase.RequestValues<br>    <strong>class</strong> <strong>ResponseValue</strong>(<strong>val</strong> posts: List&lt;Post&gt;) : UseCase.ResponseValue<br>}</pre><p><strong>The purpose of the </strong>UseCase<strong>s is to be a mediator between your </strong>ViewModel<strong>s and </strong>Repository<strong>s.</strong></p><p>Let’s say in the future you decide to add an “edit post” feature. All you have to do is add a new EditPost UseCase and all its code will be completely separate and decoupled from other UseCases. <strong>We’ve all seen it many times: New features are introduced and they inadvertently break something in preexisting code.</strong> Creating a separate UseCase helps immensely in avoiding that.</p><p>Of course, you can’t eliminate that possibility 100 percent, but you sure can minimize it. This is what separates Clean Architecture from other patterns: The code is so decoupled that you can treat every layer as a black box.</p><h3>The Data Layer</h3><p>This has all the repositories which the domain layer can use. This layer exposes a data source API to outside classes:</p><pre><strong>interface</strong> <strong>PostDataSource</strong> {</pre><pre>    <strong>interface</strong> <strong>LoadPostsCallback</strong> {<br>        <strong>fun</strong> <strong>onPostsLoaded</strong>(posts: <strong>List</strong>&lt;<strong>Post</strong>&gt;)<br>        <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>)<br>    }</pre><pre>    <strong>interface</strong> <strong>SaveTaskCallback</strong> {<br>        <strong>fun</strong> <strong>onSaveSuccess</strong>()<br>        <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>)<br>    }</pre><pre>    <strong>fun</strong> <strong>getPosts</strong>(userId: <strong>Int</strong>, callback: <strong>LoadPostsCallback</strong>)<br>    <strong>fun</strong> <strong>savePost</strong>(post: <strong>Post</strong>)<br>}</pre><p>PostDataRepository implements PostDataSource. It decides whether we fetch data from a local database or a remote server.</p><pre><strong>class</strong> <strong>PostDataRepository</strong> <strong>private</strong> <strong>constructor</strong>(<br>        <strong>private</strong> <strong>val</strong> localDataSource: PostDataSource,<br>        <strong>private</strong> <strong>val</strong> remoteDataSource: PostDataSource): PostDataSource {</pre><pre>    <strong>companion</strong> <strong>object</strong> {<br>        <strong>private</strong> <strong>var</strong> INSTANCE: PostDataRepository? = null<br>        <strong>fun</strong> <strong>getInstance</strong>(localDataSource: <strong>PostDataSource</strong>,<br>        remoteDataSource: <strong>PostDataSource</strong>): PostDataRepository {<br>            <strong>if</strong> (INSTANCE == null) {<br>                INSTANCE = PostDataRepository(localDataSource, remoteDataSource)<br>            }<br>            <strong>return</strong> INSTANCE!!<br>        }<br>    }<br>    <strong>var</strong> isCacheDirty = false<br>    <strong>override</strong> <strong>fun</strong> <strong>getPosts</strong>(userId: <strong>Int</strong>, callback: <strong>PostDataSource</strong>.<strong>LoadPostsCallback</strong>) {<br>        <strong>if</strong> (isCacheDirty) {<br>            getPostsFromServer(userId, callback)<br>        } <strong>else</strong> {<br>            localDataSource.getPosts(userId, <strong>object</strong> : PostDataSource.LoadPostsCallback {<br>                <strong>override</strong> <strong>fun</strong> <strong>onPostsLoaded</strong>(posts: <strong>List</strong>&lt;<strong>Post</strong>&gt;) {<br>                    refreshCache()<br>                    callback.onPostsLoaded(posts)<br>                }<br>                <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>                    getPostsFromServer(userId, callback)<br>                }<br>            })<br>        }<br>    }<br>    <strong>override</strong> <strong>fun</strong> <strong>savePost</strong>(post: <strong>Post</strong>) {<br>        localDataSource.savePost(post)<br>        remoteDataSource.savePost(post)<br>    }<br>    <strong>private</strong> <strong>fun</strong> <strong>getPostsFromServer</strong>(userId: <strong>Int</strong>, callback: <strong>PostDataSource</strong>.<strong>LoadPostsCallback</strong>) {<br>        remoteDataSource.getPosts(userId, <strong>object</strong> : PostDataSource.LoadPostsCallback {<br>            <strong>override</strong> <strong>fun</strong> <strong>onPostsLoaded</strong>(posts: <strong>List</strong>&lt;<strong>Post</strong>&gt;) {<br>                refreshCache()<br>                refreshLocalDataSource(posts)<br>                callback.onPostsLoaded(posts)<br>            }<br>            <strong>override</strong> <strong>fun</strong> <strong>onError</strong>(t: <strong>Throwable</strong>) {<br>                callback.onError(t)<br>            }<br>        })<br>    }<br>    <strong>private</strong> <strong>fun</strong> <strong>refreshLocalDataSource</strong>(posts: <strong>List</strong>&lt;<strong>Post</strong>&gt;) {<br>        posts.forEach {<br>            localDataSource.savePost(it)<br>        }<br>    }<br>    <strong>private</strong> <strong>fun</strong> <strong>refreshCache</strong>() {<br>        isCacheDirty = false<br>    }<br>}</pre><p>The code is mostly self-explanatory. This class has two variables, localDataSource and remoteDataSource. Their type is PostDataSource, so we don’t care how they are actually implemented under the hood.</p><p>In my personal experience, this architecture has proved to be invaluable. In one of my apps, I started with Firebase on the back end which is great for quickly building your app. I knew eventually I’d have to shift to my own server.</p><p>When I did, <strong>all I had to do was change the implementation in </strong>RemoteDataSource<strong>. I didn’t have to touch any other class even after such a huge change.</strong> That is the advantage of decoupled code. Changing any given class shouldn’t affect other parts of your code.</p><p>Some of the extra classes we have are:</p><pre><strong>interface</strong> <strong>UseCaseScheduler</strong> {</pre><pre>    <strong>fun</strong> <strong>execute</strong>(runnable: <strong>Runnable</strong>)</pre><pre>    <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>notifyResponse</strong>(response: <strong>V</strong>,<br>                                                   useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;)</pre><pre>    <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>onError</strong>(<br>            useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;, t: <strong>Throwable</strong>)<br>}<br></pre><pre><strong>class</strong> <strong>UseCaseThreadPoolScheduler</strong> : <strong>UseCaseScheduler {</strong></pre><pre>    <strong>val</strong> POOL_SIZE = 2</pre><pre>    <strong>val</strong> MAX_POOL_SIZE = 4</pre><pre>    <strong>val</strong> TIMEOUT = 30</pre><pre>    <strong>private</strong> <strong>val</strong> mHandler = Handler()</pre><pre>    <strong>internal</strong> <strong>var</strong> mThreadPoolExecutor: ThreadPoolExecutor</pre><pre>    <strong>init</strong> {<br>        mThreadPoolExecutor = ThreadPoolExecutor(POOL_SIZE, MAX_POOL_SIZE, TIMEOUT.toLong(),<br>                TimeUnit.SECONDS, ArrayBlockingQueue(POOL_SIZE))<br>    }</pre><pre>    <strong>override</strong> <strong>fun</strong> <strong>execute</strong>(runnable: <strong>Runnable</strong>) {<br>        mThreadPoolExecutor.execute(runnable)<br>    }</pre><pre>    <strong>override</strong> <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>notifyResponse</strong>(response: <strong>V</strong>,<br>                                                   useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;) {<br>        mHandler.post { useCaseCallback.onSuccess(response) }<br>    }</pre><pre>    <strong>override</strong> <strong>fun</strong> <strong>&lt;V : UseCase.ResponseValue&gt;</strong> <strong>onError</strong>(<br>            useCaseCallback: <strong>UseCase</strong>.<strong>UseCaseCallback</strong>&lt;<strong>V</strong>&gt;, t: <strong>Throwable</strong>) {<br>        mHandler.post { useCaseCallback.onError(t) }<br>    }</pre><pre>}</pre><p>UseCaseThreadPoolScheduler is responsible for executing tasks asynchronously using ThreadPoolExecuter.</p><pre><strong>class</strong> <strong>ViewModelFactory</strong> : <strong>ViewModelProvider.Factory {</strong><br></pre><pre>    <strong>override</strong> <strong>fun</strong> <strong>&lt;T : ViewModel&gt;</strong> <strong>create</strong>(modelClass: <strong>Class</strong>&lt;<strong>T</strong>&gt;): T {<br>        <strong>if</strong> (modelClass == PostListViewModel::<strong>class</strong>.<strong>java</strong>) {<br>            <strong>return</strong> PostListViewModel(<br>                    Injection.provideUseCaseHandler()<br>                    , Injection.provideGetPosts(), Injection.provideSavePost()) <strong>as</strong> T<br>        }<br>        <strong>throw</strong> IllegalArgumentException(&quot;unknown model class $modelClass&quot;)<br>    }</pre><pre>    <strong>companion</strong> <strong>object</strong> {<br>        <strong>private</strong> <strong>var</strong> INSTANCE: ViewModelFactory? = null<br>        <strong>fun</strong> <strong>getInstance</strong>(): ViewModelFactory {<br>            <strong>if</strong> (INSTANCE == null) {<br>                INSTANCE = ViewModelFactory()<br>            }<br>            <strong>return</strong> INSTANCE!!<br>        }<br>    }<br>}</pre><p>This is our ViewModelFactory. You have to create this to pass arguments in your ViewModel constructor.</p><h3>Dependency Injection</h3><p>I’ll explain dependency injection with an example. If you look at our PostDataRepositoryclass, it has two dependencies, LocalDataSource and RemoteDataSource. We use the Injection class to provide these dependencies to the PostDataRepository class.</p><p>Injecting dependency has two main advantages. One is that you get to control the instantiation of objects from a central place instead of spreading it across the whole codebase. Another is that this will help us write unit tests for PostDataRepositorybecause now we can just pass mocked versions of LocalDataSource and RemoteDataSource to the PostDataRepository constructor instead of actual values.</p><pre><strong>object</strong> Injection {</pre><pre>    <strong>fun</strong> <strong>providePostDataRepository</strong>(): PostDataRepository {<br>        <strong>return</strong> PostDataRepository.getInstance(provideLocalDataSource(), provideRemoteDataSource())<br>    }</pre><pre>    <strong>fun</strong> <strong>provideViewModelFactory</strong>() = ViewModelFactory.getInstance()</pre><pre>    <strong>fun</strong> <strong>provideLocalDataSource</strong>(): PostDataSource = LocalDataSource.getInstance()</pre><pre>    <strong>fun</strong> <strong>provideRemoteDataSource</strong>(): PostDataSource = RemoteDataSource.getInstance()</pre><pre>    <strong>fun</strong> <strong>provideGetPosts</strong>() = GetPosts(providePostDataRepository())</pre><pre>    <strong>fun</strong> <strong>provideSavePost</strong>() = SavePost(providePostDataRepository())</pre><pre>    <strong>fun</strong> <strong>provideUseCaseHandler</strong>() = UseCaseHandler.getInstance()<br>}</pre><p>Note: I prefer using Dagger 2 for dependency injection in complex projects. But with its extremely steep learning curve, it’s beyond the scope of this article. So if you’re interested in going deeper, I highly recommend <a href="https://medium.com/@harivigneshjayapalan/dagger-2-for-android-beginners-dagger-2-part-i-f2de5564ab25">Hari Vignesh Jayapalan’s introduction to Dagger 2</a>.</p><p>See you in the next tutorial, but for the time being I bid adieu :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef47ca7b0795" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Computer controlling of cell fermentation in manufacturing of drugs in pharma companies]]></title>
            <link>https://medium.com/ai-techsystems/computer-controlling-of-cell-fermentation-in-manufacturing-of-drugs-in-pharma-companies-94dd5e0640bb?source=rss-746d5e27c5e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/94dd5e0640bb</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Mohammad Sharique]]></dc:creator>
            <pubDate>Mon, 29 Jul 2019 14:36:15 GMT</pubDate>
            <atom:updated>2019-08-18T05:06:05.827Z</atom:updated>
            <content:encoded><![CDATA[<p>Implementing ML and AI algorithms and intelligence system in the biotech industry is still a big leap. Some undergraduates at VIT University, Vellore has an article published in the scholar research library of which I will provide the link which details the modus of computer controlling bacillus fermentation while assuring simultaneously good sporulation percentage(&gt;90%).</p><p>The concern is to improve the reliability and dynamicity of drug manufacturing by cultivating on data from a previous post-manufacturing step.</p><p>Determining sporulation percentage considering theta(as parameter)which can be Maltodextrin %, Yeast extract, NaCl and many many parameters to reach targetted percentage in an amount of time which can be machine learning algorithm controlled. So that less time is taken and also at the same time favorable percentage comes out. My research on implementing Machine Learning and AI on the biotech industry deliverance are still going on. Link to my work on researchgate: <a href="https://www.researchgate.net/publication/334635420_Machine_learning_algorithms_for_SaaS_to_make_biotech_industry_AI-First_enterprise">https://www.researchgate.net/publication/334635420_Machine_learning_algorithms_for_SaaS_to_make_biotech_industry_AI-First_enterprise</a> Kindly give citations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*LXFcV4OVwtuVr3EMlbbw_Q.png" /></figure><p><strong>Computer software controller for monitoring of fermentation process with special reference to pectinase producing actinomycetes</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=94dd5e0640bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ai-techsystems/computer-controlling-of-cell-fermentation-in-manufacturing-of-drugs-in-pharma-companies-94dd5e0640bb">Computer controlling of cell fermentation in manufacturing of drugs in pharma companies</a> was originally published in <a href="https://medium.com/ai-techsystems">AITS Journal</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>