<?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 Mayur Pethani on Medium]]></title>
        <description><![CDATA[Stories by Mayur Pethani on Medium]]></description>
        <link>https://medium.com/@mayurmorin?source=rss-257648bdd966------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_oYB_lgCnVbI0Kay.</url>
            <title>Stories by Mayur Pethani on Medium</title>
            <link>https://medium.com/@mayurmorin?source=rss-257648bdd966------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 16:29:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mayurmorin/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[Automated Essay Scoring — Kaggle Competition End to End Project Implementation-Part 3]]></title>
            <link>https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccd8ae110fd4</guid>
            <category><![CDATA[essay]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 13:46:21 GMT</pubDate>
            <atom:updated>2019-11-19T04:17:45.091Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Essay Scoring — Kaggle Competition End to End Project Implementation</h3><h4>Part 3: Building a Web Application for the Project and Deploying the ML Model</h4><p>Kindly go through <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-1-b75a043903c4">Part 1</a>, <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a> and <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a> for complete understanding and project execution with given <a href="https://github.com/mayurmorin/Automated-Essay--Scoring">Github</a>.</p><p><strong>2. /mysite/grader/views.py </strong>for<strong> </strong>getting the context from web page and<strong> </strong>scoring the essay from saved model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/12e48bed3268c39bfa7712fb103c4ce0/href">https://medium.com/media/12e48bed3268c39bfa7712fb103c4ce0/href</a></iframe><ul><li>Django and utils libraries are imported where whenever user browse for web application first index function will be called which will internally call index.html file and load the same.</li><li>Essays definition will call essay.html file which will list all the essay where user or student can select which essay he/she wants to write.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2SCstT6wYG7eku1w" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e6dc04306154e972339170d9b9afe14/href">https://medium.com/media/8e6dc04306154e972339170d9b9afe14/href</a></iframe><ul><li>Question definition takes the data from form in terms of content. Students written essay will get in terms of post request and store in the content.</li></ul><pre>content = form.cleaned_data.get(&#39;answer&#39;)<br></pre><ul><li>content has been converted into the testdataVectors using below code where Word2Vec saved model is used along with previously defined functions getAvgFeatureVec.</li></ul><pre>num_features = 300<br>                model = word2vec.KeyedVectors.load_word2vec_format(os.path.join(current_path, &quot;deep_learning_files/word2vec.bin&quot;), binary=True)<br>                clean_test_essays = []<br>                clean_test_essays.append(essay_to_wordlist( content, remove_stopwords=True ))<br>                testDataVecs = getAvgFeatureVecs( clean_test_essays, model, num_features )<br>                testDataVecs = np.array(testDataVecs)<br>                testDataVecs = np.reshape(testDataVecs, (testDataVecs.shape[0], 1, testDataVecs.shape[1]))</pre><ul><li>Now final_lstm.h5 model weights have been loaded and prediction is done in terms of score.</li></ul><pre>lstm_model = get_model()<br>  lstm_model.load_weights(os.path.join(current_path, &quot;deep_learning_files/final_lstm.h5&quot;))<br>preds = lstm_model.predict(testDataVecs)<br><strong>if</strong> math.isnan(preds):<br>                    preds = 0<br>                <strong>else</strong>:<br>                    preds = np.around(preds)<br><br>                <strong>if</strong> preds &lt; 0:<br>                    preds = 0<br>                <strong>if</strong> preds &gt; question.max_score:<br>                    preds = question.max_score<br>            <strong>else</strong>:<br>                preds = 0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FvzOMAF5fzdgCjCq" /></figure><pre>essay = Essay.objects.create(<br>                content=content,<br>                question=question,<br>                score=preds<br>            )<br>        <strong>return</strong> redirect(&#39;essay&#39;, question_id=question.set, essay_id=essay.id)<br>    <strong>else</strong>:<br>        form = AnswerForm()<br><br>    context = {<br>        &quot;question&quot;: question,<br>        &quot;form&quot;: form,<br>    }<br>    <strong>return</strong> render(request, &#39;grader/question.html&#39;, context)</pre><ul><li>Here predicted score has been passed back to question.html and score has been shown into the html page.</li></ul><p><strong>This is complete End to End Project Implementation of Automated Essay Scoring. Hip Hip Hurray !!!</strong></p><h3><strong>Summary:</strong></h3><ol><li>You can try different neural network models as mentioned in the models folder and try to check different accuracy and see if you can increase the score.</li><li>You can also use here pretrained models like GloVe, FastText or other state of art models as part of transfer learning which are currently in use.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*OcXxOGpCq6zjZqOHCp_bPg.png" /></figure><p>3. If some of the code, you are not able to understand, then kindly Google it out for better understanding, by doing it your concepts will become much more clear.</p><p>4. There are 2 Research Paper mentioned which are good to go through so that you can get practise of it and they also gives clear picture of whole project.</p><p>Kindly go through Part 1 and <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a> for complete understanding and project execution with given Github link.</p><h3><strong>References:</strong></h3><ol><li>Special thanks goes to Ronit Mankad’s Github Repo which I had forked and got end to end understanding about this project.</li><li>References taken from Wikipedia and other websites.</li><li><a href="http://aclweb.org/anthology/D/D16/D16-1193.pdf">A Neural Approach to Automated Essay Scoring</a></li><li><a href="https://arxiv.org/pdf/1606.04289.pdf">Automatic Text Scoring Using Neural Networks</a></li></ol><p><strong>If you really like this article series, kindly clap, follow me and enjoy the extreme power of artificial intelligence just like below minions.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lz_twaj-e9SFYuXc.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccd8ae110fd4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Automated Essay Scoring — Kaggle Competition End to End Project Implementation-Part 3</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[Automated Essay Scoring — Kaggle Competition End to End Project Implementation-Part 2]]></title>
            <link>https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9fb4c31aed8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[essay]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 13:40:09 GMT</pubDate>
            <atom:updated>2019-11-18T06:37:41.220Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Essay Scoring — Kaggle Competition End to End Project Implementation</h3><h4>Part 2: Data Preprocessing and Trainign with LSTM</h4><p>Kindly go through <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-1-b75a043903c4">Part 1</a>, <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a> and <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a> for complete understanding and project execution with given <a href="https://github.com/mayurmorin/Automated-Essay--Scoring">Github</a>.</p><ol><li><strong>Training LSTM Model.ipynb </strong>for training and saving the model.</li></ol><h3><strong>Importing the Data</strong></h3><ul><li>Gensim, NLTK, Django libraries have been added.</li><li>Constants have been added in terms of DATASET_DIR, GLOVE_DIR, SAVE_DIR paths.</li><li>Loading data using pandas library from training_set_rel3.tsv.</li><li>Removing unnecessary columns like domain_score and raters_domain.</li><li>Defining Minimum and Maximum score which we will be using at the time of predicting the actual score.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04bf2af9b8d4e55d07a504dc0435f834/href">https://medium.com/media/04bf2af9b8d4e55d07a504dc0435f834/href</a></iframe><h3>Preprocessing the Data</h3><p>We will preprocess all essays and convert them to feature vectors so that they can be fed into the RNN.</p><p>These are all helper functions used to clean the essays.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3721859ba975edf88b0736f682665496/href">https://medium.com/media/3721859ba975edf88b0736f682665496/href</a></iframe><ul><li>There are 4 functions defined:</li></ul><ol><li><strong>getAvgFeatureVecs</strong>: This function accepts 3 parameters: essays, model, num_features. It internall calls <strong>makeFeatureVec</strong> function to convert essays into FeatureVector.</li><li><strong>makeFeatureVec:</strong> This function accepts 3 parameters: words, model, num_features. Using Word2Vec index2word function and np.divide it gives ultimately average feature vectors for the passed model.</li><li><strong>essay_to_sentense</strong>: This function accepts 2 parameters: essay_v, remove_stopwords. it internally calls essay_to_wordlist and converts essays to sentences.</li><li><strong>essay_to_wordlist</strong>: This function accepts 2 parameters: essay_v, remove_stopwords. It removes the stopwords and returns words.</li></ol><ul><li>Whenever you are working with NLP Machine Learning and Deep Learning tasks the above mentioned steps are almost neccessary because machine understands numbers or we can say that computation is very easy when we use numbers here we refer to vectors.</li><li>We are trying to convert essay or corpus to first sentenses and then to words which can also be called are tokens and then convert them to vectors.</li></ul><blockquote><strong>I would strongly suggest to go through few NLP terminology and concepts like Tokenizer, Stemming, Limitization, Stopwords, different methods to convert words to Vectors like BOW, TF-IDF, n-gram. These are NLP data pre-processing techniques before feeding to any machine learning algorithms or deep learning algorithms.</strong></blockquote><h3>Defining the model</h3><p>Here we define a 2-Layer LSTM Model.</p><p>Note that instead of using sigmoid activation in the output layer we will use Relu since we are not normalising training labels.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/77aa371edee34b02ffd5a91c0c9db80d/href">https://medium.com/media/77aa371edee34b02ffd5a91c0c9db80d/href</a></iframe><ul><li>/models folder contains 6 different models which you should try and check accuracy.</li><li>As part of training, you just need to replace above code with those model files code</li></ul><h3>Training Phase</h3><p>Now we train the model on the dataset.</p><p>We will use 5-Fold Cross Validation and measure the Quadratic Weighted Kappa for each fold. We will then calculate Average Kappa for all the folds.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b024c42937143fc94660bc6b4d82b061/href">https://medium.com/media/b024c42937143fc94660bc6b4d82b061/href</a></iframe><ul><li>We are first training the essays using Word2Vec model which is available in gensim library. Later on, we are saving into word2vecmodel.bin file which we will be using at the time of predicting the score.</li></ul><pre>print(&quot;Training Word2Vec Model...&quot;)<br>    model = Word2Vec(sentences, workers=num_workers, size=num_features, min_count = min_word_count, window = context, sample = downsampling)<br><br>    model.init_sims(replace=<strong>True</strong>)<br>    model.wv.save_word2vec_format(&#39;word2vecmodel.bin&#39;, binary=<strong>True</strong>)</pre><ul><li>Now we are using the functions which we have previously defined to convert essay to vector representation.</li><li>We are also passing this vectors into LSTM model and saving the model in final_lstm.h5 file.</li><li>As part of result, we are calculating cohen kapp score with quadratic weights for 5 times using KFold cross validation and then we are taking the average. As you can see the result will be</li></ul><pre>print(&quot;Average Kappa score after a 5-fold cross validation: &quot;,np.around(np.array(results).mean(),decimals=4))<br><strong>Average Kappa score after a 5-fold cross validation:  0.9615</strong></pre><h3>References</h3><ol><li><a href="http://aclweb.org/anthology/D/D16/D16-1193.pdf">A Neural Approach to Automated Essay Scoring</a></li><li><a href="https://arxiv.org/pdf/1606.04289.pdf">Automatic Text Scoring Using Neural Networks</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*mfiehGJhPa-lOtzPZpXgeA.png" /><figcaption><strong>Research Paper</strong></figcaption></figure><p>The above research papers clearly explains the importance of using cohen’s kappa score as well as different Models they have tried in their research and which model has given the best result.</p><p><strong>IMPORTANT: In practical project implementation also this is very important that you must try with different models to get maximum accuracy and then that model will be saved and used as a part of production.</strong></p><p>Next, we will be going through Web Application code where we will see how saved model is actually predicting the score in <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a>.</p><h3>References:</h3><ol><li>Special thanks goes to Ronit Mankad’s Github Repo which I had forked and got end to end understanding about this project.</li><li>References taken from Wikipedia and other websites.</li><li><a href="http://aclweb.org/anthology/D/D16/D16-1193.pdf">A Neural Approach to Automated Essay Scoring</a></li><li><a href="https://arxiv.org/pdf/1606.04289.pdf">Automatic Text Scoring Using Neural Networks</a></li></ol><p><strong>If you really like this article series, kindly clap, follow me and enjoy the extreme power of artificial intelligence just like below minions.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lz_twaj-e9SFYuXc.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9fb4c31aed8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Automated Essay Scoring — Kaggle Competition End to End Project Implementation-Part 2</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[Automated Essay Scoring: Kaggle Competition —  End to End Project Implementation]]></title>
            <link>https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-1-b75a043903c4?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/b75a043903c4</guid>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[projects]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 13:17:22 GMT</pubDate>
            <atom:updated>2019-11-15T04:18:58.972Z</atom:updated>
            <content:encoded><![CDATA[<h3>Automated Essay Scoring: Kaggle Competition — End to End Project Implementation</h3><h4>Part 1: Problem Definition, Building the architecture, and Prerequisites</h4><p>Kindly go through <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-1-b75a043903c4">Part 1</a>, <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a> and <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a> for complete understanding and project execution with given <a href="https://github.com/mayurmorin/Automated-Essay--Scoring">Github</a>.</p><p>Let’s first understand the meaning of automated essay scoring. In our education system, different students write essays as part of their examination and teacher’s grade them based on their essay writing skills. The question here is can this be automated and at what extent?</p><p><strong>Definition</strong>: As per Wikipedia, it has been explained pretty well as follows:</p><blockquote><strong>Automated essay scoring</strong> (<strong>AES</strong>) is the use of specialized computer programs to assign grades to essays written in an educational setting. It is a of <a href="https://en.wikipedia.org/wiki/Educational_assessment">educational assessment</a> and an application of <a href="https://en.wikipedia.org/wiki/Natural_language_processing">natural language processing</a>. Its objective is to classify a large set of textual entities into a small number of discrete categories, corresponding to the possible grades — for example, the numbers 1 to 6. Therefore, it can be considered a problem of <a href="https://en.wikipedia.org/wiki/Statistical_classification">statistical classification</a>.</blockquote><p><strong>Competition</strong>: In 2012, the Hewlett Foundation sponsored a competition on Kaggle called Automated Student Assessment Prize. You can go through this link <a href="https://www.kaggle.com/c/asap-aes/overview">ASAP</a> for further details.</p><p><strong>Dataset</strong>: For this competition, there are eight essay sets. Each of the sets of essays was generated from a single prompt. Selected essays range from an average length of 150 to 550 words per response. Some of the essays are dependent upon source information and others are not. All responses were written by students ranging in grade levels from Grade 7 to Grade 10. All essays were hand graded and were double-scored. Each of the eight data sets has its own unique characteristics. The variability is intended to test the limits of your scoring engine’s capabilities.</p><p>The training data is provided in three formats: a tab-separated value (TSV) file, a Microsoft Excel 2010 spreadsheet, and a Microsoft Excel 2003 spreadsheet. The current release of the training data contains essay sets 1–6. Sets 7–8 will be released on February 10, 2012. Each of these files contains 28 columns:</p><ul><li>essay_id: A unique identifier for each individual student essay</li><li>essay_set: 1–8, an id for each set of essays</li><li>essay: The ascii text of a student’s response</li><li>rater1_domain1: Rater 1’s domain 1 score; all essays have this</li><li>rater2_domain1: Rater 2’s domain 1 score; all essays have this</li><li>rater3_domain1: Rater 3’s domain 1 score; only some essays in set 8 have this.</li><li>domain1_score: Resolved score between the raters; all essays have this</li><li>rater1_domain2: Rater 1’s domain 2 score; only essays in set 2 have this</li><li>rater2_domain2: Rater 2’s domain 2 score; only essays in set 2 have this</li><li>domain2_score: Resolved score between the raters; only essays in set 2 have this rater1_trait1 score — rater3_trait6 score: trait scores for sets 7–8</li></ul><p>As mentioned in Kaggle competition, we have used training_set_rel3.tsv file in our coding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*2uih1WEeCeQKMlpWqtdw5g.png" /><figcaption><strong>Figure 1 training_set_rel3.tsv</strong></figcaption></figure><p>As you can see in the essay column, @CAPS1, @CAPS2, @NUM1 has been mentioned. So for this, the competition sponsors have made an effort to remove personally identifying information from the essays using the <a href="http://nlp.stanford.edu/software/CRF-NER.shtml">Named Entity Recognizer (NER)</a> from the Stanford Natural Language Processing group and a variety of other approaches. The relevant entities are identified in the text and then replaced with a string such as “@PERSON1.”</p><p>The entities identified by NER are: “PERSON”, “ORGANIZATION”, “LOCATION”, “DATE”, “TIME”, “MONEY”, and “PERCENT”.</p><p>I have given here basic understanding of Kaggle Competition what actually required but for detailed study of required and dataset, kindly go through the link <a href="https://www.kaggle.com/c/asap-aes">ASAP</a>.</p><p><strong>EXTREMELY IMPORTANT</strong>: Note that this competition happened <strong>8 years go</strong> and in the Leader board who got the first prize had <strong>score of 0.81407</strong>. We are going to break this record and achieve the <strong>score of 0.96. Surely we can say that at that time deep learning had some limitations which we don’t have now.</strong></p><p>Kindly go through the <a href="https://github.com/mayurmorin/Automated-Essay--Scoring">Github</a> link for all the coding and you can run like a web application where user can choose essays from 1 to 8 and then students can write context with respect to that essay. By clicking on button <strong>Grade Me</strong>, students will get their score on the spot for their written essay.</p><p>Below mentioned points give basic understanding of the Project:</p><ul><li>This project is developed on Django Framework. I have worked and delivered many Web Application projects on ASP.NET, MVC Web API, Angular JS and latest on the Flask. For executing this web application on server, you may not require complete understanding of Django Framework. As per Github guidelines, you will be able to host on server easily.</li><li>As part of Data Science Life Cycle, we have already cleared steps of data ingestion and few steps of data pre-processing because training data has already been provided along with little bit of pre-processing as mentioned above as part of Anonymization.</li><li>We are also using Deep Learning LSTM algorithm which has capability of learning Sequence of information. We are looking here for score so we can say that Many-to-One LSTM algorithm need to apply.</li><li>Here, we have calculated score using statistical method called Cohen kappa score. There are other statistical methods are also available which can be used for further exploration and to understand about Cohen Kappa’s few details from <a href="https://en.wikipedia.org/wiki/Cohen&#39;s_kappa">Wikipedia</a> as mentioned below (Example).</li></ul><blockquote>1. Cohen’s kappa measures the agreement between two raters who each classify N items into C mutually exclusive categories. The definition of is:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*Y0_qrroes8nKvhBylkWWqg.png" /></figure><blockquote>Where po is the relative observed agreement among raters (identical to accuracy), and pe is the hypothetical probability of chance agreement, using the observed data to calculate the probabilities of each observer randomly seeing each category.</blockquote><blockquote>2. If the raters are in complete agreement then k=1. If there is no agreement among the raters other than what would be expected by chance (as given by pe), k=0. It is possible for the statistic to be negative, which implies that there is no effective agreement between the two raters or the agreement is worse than random.</blockquote><ul><li>As per part of NLP, Essays will be further processed under sentence and then into tokens using NLTK library along with usage of regular expressions. We will be converting into Vectors to feed LSTM using Word2Vec algorithm and also using pretrained model of GloVe.</li><li>We will be creating Neural Network architecture using LSTM and feeding our feature Vectors to this Neural Network. We can prepared n number of different Neural Network architecture and check which Neural Network gives best output.</li><li>We will also go through 2 Research Papers related to Automated Essay Scoring and get little bit of insights of it. The link of research papers are already mention in Github link at last.</li><li>Here, we will be training the model and saving this model into <strong>h5 format </strong>which is of <strong>Keras</strong>. Please note that <strong>Scikit learn model</strong> you will be saving in <strong>pickle file format pkl</strong>. <strong>Tensorflow model</strong> you can save in <strong>protobuf file format (.pb)</strong>.</li><li>I will also explain few code snippets of essay load web page, when we are clicking on Grade Me button, we will be loading these saved models and how are we calculating the score.</li><li>I will be going through mainly 2 files:</li></ul><ol><li><strong>Training LSTM Model.ipynb </strong>for training and saving the model. (<a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a>)</li><li><strong>/mysite/grader/views.py </strong>for<strong> </strong>getting the context from web page and<strong> </strong>scoring the essay from saved model. (<a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a>)</li></ol><p>Kindly go through <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-2-a9fb4c31aed8">Part 2</a> and <a href="https://medium.com/@mayurmorin/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-3-ccd8ae110fd4">Part 3</a> for complete understanding and project execution.</p><h3>References:</h3><ol><li>Special thanks goes to Ronit Mankad’s Github Repo which I had forked and got end to end understanding about this project.</li><li>References taken from Wikipedia and other websites.</li><li><a href="http://aclweb.org/anthology/D/D16/D16-1193.pdf">A Neural Approach to Automated Essay Scoring</a></li><li><a href="https://arxiv.org/pdf/1606.04289.pdf">Automatic Text Scoring Using Neural Networks</a></li></ol><p><strong>If you really like this article series, kindly clap, follow me and enjoy the extreme power of artificial intelligence just like below minions.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*lz_twaj-e9SFYuXc.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b75a043903c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/automated-essay-scoring-kaggle-competition-end-to-end-project-implementation-part-1-b75a043903c4">Automated Essay Scoring: Kaggle Competition —  End to End Project Implementation</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[Making of Chatbot using Rasa NLU & Rasa Core-Part 3]]></title>
            <link>https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-3-ea836c1c3527?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea836c1c3527</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[weather]]></category>
            <category><![CDATA[chatbots]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Thu, 07 Nov 2019 13:47:13 GMT</pubDate>
            <atom:updated>2019-11-13T13:06:12.026Z</atom:updated>
            <content:encoded><![CDATA[<p>Kindly check for <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-1-7138c438581f"><strong>Part 1</strong></a>, <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-2-e1dbd9b30b1e"><strong>Part 2</strong></a> and <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-3-ea836c1c3527"><strong>Part 3</strong></a> for complete chatbot execution.</p><p><strong>LEVEL 3: Integrating RASA Core dialogue management model with Slack Messenger User Interface:</strong></p><p><strong>You can follow the video with the given link </strong><a href="https://jpboost.com/2018/02/06/creating-a-chatbot-with-rasa-nlu-and-rasa-core/"><strong>here</strong></a><strong> from 1 hour and 23 minutes for better understanding.</strong></p><p>1. <strong>Configuration of Slack API</strong>:</p><p>· Open URL with <a href="https://api.slack.com/">https://api.slack.com/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*V_LKqflrO5ZUv2Y3JF4hNw.png" /></figure><p>· Click on Start Building. Create a Name for App and choose Development Slack WareHouse. If there is no workspace is available, then you need to create the one. Then click on create App.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*biXvefEEBJtIpFeEQzizzw.png" /></figure><h3>Most Popular Chatbot Tutorials</h3><blockquote><a href="https://chatbotslife.com/aws-setup-for-deep-learning-fda04db6df75">1. AWS setup for Deep Learning</a></blockquote><blockquote><a href="https://chatbotslife.com/building-a-successful-chatbot-d210bec69773">2. Building a Successful Chatbot</a></blockquote><blockquote><a href="https://chatbotslife.com/how-to-integrate-api-ai-with-chatfuel-48baafd4613">3. How to Integrate API.AI with Chatfuel</a></blockquote><blockquote><a href="https://chatbotslife.com/build-a-working-sms-chat-bot-in-10-minutes-b8278d80cc7a">4. Build a working SMS chat-bot in 10 minutes</a></blockquote><p>Once you have created slack app name, basic information page will open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*TbYFqrvXYTsNqIks6gCynQ.png" /></figure><p>Create <a href="https://chatbotslife.com/">Bot</a> user and also tick Always show My bot Online.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*B9G876GSOyCdqqasCD379Q.png" /></figure><p>2. <strong>Create rasa_slack_connector.py file which will be used as SlackInput:</strong></p><p>It will take messages from Slack and it will provide them to RASA Core whenever it is needed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62f32654c7605f83bb6e26d29dcfa69e/href">https://medium.com/media/62f32654c7605f83bb6e26d29dcfa69e/href</a></iframe><p><strong>3.</strong> <strong>Configuration of run_app.py:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33472374c786aea4709b3fb2a651e32e/href">https://medium.com/media/33472374c786aea4709b3fb2a651e32e/href</a></iframe><p>· This file interprets from weathernlu model which has been created from RASA NLU and loads agent from dialogue model which has been created from RASA Core.</p><p>· SlackInput takes App Verification token, <a href="https://chatbotslife.com/">Bot</a> Verification token under OAuth &amp; Permission tab and Slack Verification token under Basic Information tab.</p><p>· Slack runs on http server with 5004 port.</p><p>· <strong>Command</strong>: python run_app.py</p><p>4. <strong>Ngrok Configuration:</strong></p><p>· <strong>Ngrok should be download and run with http port 5005</strong></p><p>· <strong>Command</strong>: ngrok http 5004</p><p>· Forwarding URL should be copied and pasted into Slack Event Subscription as mentioned below:</p><p>· <a href="https://bef1381fe.ngrok.io/slack/events">https://bef1381fe.ngrok.io/slack/events</a> and save changes.</p><p>· Now, you can open your chatbot in Slack and start conversation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*_V2KqjoJzeeifReT7Gj3lg.png" /></figure><p><strong>5.</strong> <strong>Connecting a chatbot to Slack:</strong></p><p>· Configure the slack app as mentioned in above points.</p><p>· Make sure custom actions server is running.</p><p>· Start the agent by running run_app.py file (don’t forget to provide the slack_token)</p><p>· Start the ngrok on the port 5004</p><p>· Provide the url: <a href="https://your_ngrok_url/webhooks/slack/events">https://your_ngrok_url/webhooks/slack/events</a> to ‘Event Subscriptions’ page of the slack configuration.</p><p><strong>Talk to your bot. Hip Hip Hurray !!!</strong></p><p><strong>LEVEL 4: Understanding Spacy and different algorithm underneath of RASA NLU and RASA Core:</strong></p><p>· <strong>Spacy Pipeline: </strong>The article provided by Bhavani Ravi in 3 different parts — Demystifying RasaNLU explains how <a href="https://chatbotslife.com/">chatbot</a> works. The links mentioned below explains in depth understanding of RASA NLU.</p><p>1. <a href="https://hackernoon.com/demystifying-rasa-nlu-1-training-91a08429c9fb">NLP Behind Chatbots — <strong>Demystifying Rasa NLU </strong>— Part 1</a>.</p><p><strong>2.</strong> <a href="https://hackernoon.com/deploying-a-chatbot-nlp-model-demystifying-rasanlu-2-server-7704afc74d1f"><strong>NLP Behind Chatbots — Demystifying Rasa NLU — Part-2 — Serve</strong></a></p><p><strong>3.</strong> <a href="https://hackernoon.com/entity-extraction-demistifying-rasanlu-part-3-13a460451573"><strong>Entity Extraction — Demystifying Rasa NLU — Part 3</strong></a></p><p>· <strong>Algorithm underneath of RASA NLU and RASA Core</strong>:</p><p>1. <strong>RASA NLU</strong>: NLP (Natural Language Processing)</p><p>o Spacy NLP</p><p>o SpacyTokenizer (Converts to Tokens)</p><p>o SpacyFeaturizer (Converts tokens to vectors) Word2Vec</p><p>o EntityExtractor (NER_CRF) (Named Entity Recognition with Conditional Random fields)</p><p>— Sequential Statistics Model</p><p>— Every feature is dependent on feature before and after it and it is important to preserve the order.</p><p>— BILOU Tagging (Begin, Intermediate, Last, Others, Unigram)</p><p>— Convert into CRF format</p><p>— Predict in JSON Format</p><p>o IntentClassifer:</p><p>— Tokenize text to words.</p><p>— Convert words to features</p><p>— Word2Vec Algorithm (N-Dimensional Space)</p><p>— Labeling Featuers</p><p>— Supervised Word Vector algorithm</p><p><strong>2.</strong> <strong>RASA CORE (Next Action):</strong></p><p>1. Policies: Choose Next actions</p><p>· Memoization Policy: Remembers or byheart the previous actions</p><p>· Keras Policy: RNN (Recurrent Nueral Networks) Long Term Short Memory</p><p><strong>NOTE</strong>: For all the code I have added into this article are not aligned. Kindly refer to <a href="https://github.com/JustinaPetr/Weatherbot_Tutorial/"><strong>Github</strong></a> for actual code.</p><p><strong>Kindly let me know your feedback or input to make this article much better along with your claps and also, if you are facing any issue regarding creating of Weatherbot.</strong></p><p>Well, that’s the end of my implementation and understanding of making a simple chatbot using RASA NLU and RASA core. I had multiple links and documents some of which mentioned below.</p><p><strong>Useful Reference Links:</strong></p><p>· Special thanks to Justina Petraitytė who has guided me to do my first Weatherbot from <a href="https://jpboost.com/2018/02/06/creating-a-chatbot-with-rasa-nlu-and-rasa-core/">here</a>.</p><p>· In-depth understanding of RASA NLU given by Bhavani Ravi in her Demystifying RASA NLU <a href="https://hackernoon.com/demystifying-rasa-nlu-1-training-91a08429c9fb">series</a>.</p><p>· <a href="https://github.com/RasaHQ/rasa_nlu"><strong>Rasa NLU documentation</strong></a></p><p>· <a href="https://github.com/RasaHQ/rasa_core"><strong>Rasa Core documentation</strong></a></p><h3>Don’t forget to give us your 👏 !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*ZxaGcKC3UQEydQIX" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e59ef%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e59ef&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e59ef%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href">https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href</a></iframe><figure><a href="https://chatbotslife.com/bot-communities-mastermind-group-d2dae9876709#.53x0py6ou"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*6XUspT9JOSq0w0Fi35HIaA.png" /></a></figure><figure><a href="https://m.me/ChatbotsLife"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*c1LDMH5vbnIz9rmAka8Hwg.png" /></a></figure><figure><a href="https://chatbotslife.com/chatbot-development-hire-top-ai-chatbot-developers-c8b45ef7f207"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*D0Jf3dI6ZThtqcfwDYY7mg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea836c1c3527" width="1" height="1" alt=""><hr><p><a href="https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-3-ea836c1c3527">Making of Chatbot using Rasa NLU &amp; Rasa Core-Part 3</a> was originally published in <a href="https://blog.chatbotslife.com/">Chatbots Life</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making of Chatbot using Rasa NLU & Rasa Core-Part 2]]></title>
            <link>https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-2-e1dbd9b30b1e?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1dbd9b30b1e</guid>
            <category><![CDATA[rasa-nlu]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Thu, 07 Nov 2019 13:44:37 GMT</pubDate>
            <atom:updated>2019-11-13T13:06:24.112Z</atom:updated>
            <content:encoded><![CDATA[<p>Kindly check for <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-1-7138c438581f"><strong>Part 1</strong></a>, <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-2-e1dbd9b30b1e"><strong>Part 2</strong></a> and <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-3-ea836c1c3527"><strong>Part 3</strong></a> for complete chatbot execution.</p><p><strong>LEVEL 2:</strong> <strong>Creating an intermediate program using RASA Core and its dialogue management model where chatbot interacts at the command prompt level:</strong></p><p>In <a href="https://medium.com/p/7138c438581f/edit"><strong>LEVEL 1</strong></a>, we have learned about how RASA NLU interprets user input and extracts relevant intent and entity, but we are looking for a <a href="https://chatbotslife.com/">chatbot</a> which interacts instinctually and continuously. Basically, User should be able to do chatting with a bot just like having normal communication or conversation. This can be achieved by RASA Core and let’s first understand the architecture of RASA Core.</p><ol><li><strong>RASA Core Architecture:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*yva9xlYSkFRJnroCXhVSqw.png" /><figcaption><strong>Figure-5 RASA Core architecture</strong></figcaption></figure><ol><li>The message is received and passed to <strong>an Interpreter</strong>, which converts it into a dictionary including the original text, the intent, and any entities that were found.</li></ol><h3>Most Popular Chatbot Tutorials</h3><blockquote><a href="https://chatbotslife.com/aws-setup-for-deep-learning-fda04db6df75">1. AWS setup for Deep Learning</a></blockquote><blockquote><a href="https://chatbotslife.com/building-a-successful-chatbot-d210bec69773">2. Building a Successful Chatbot</a></blockquote><blockquote><a href="https://chatbotslife.com/how-to-integrate-api-ai-with-chatfuel-48baafd4613">3. How to Integrate API.AI with Chatfuel</a></blockquote><blockquote><a href="https://chatbotslife.com/build-a-working-sms-chat-bot-in-10-minutes-b8278d80cc7a">4. Build a working SMS chat-bot in 10 minutes</a></blockquote><p>2. <strong>The Tracker</strong> is the object which keeps track of conversation state. It receives the info that a new message has come in.</p><p>3. <strong>The policy</strong> receives the current state of the tracker.</p><p>4. The policy chooses which action to take next.</p><p>5. The chosen action is logged by the tracker.</p><p>6. A response is sent to the user.</p><p>You can get further details in this <a href="https://rasa.com/docs/core/architecture/">link</a>.</p><p><strong>2.</strong> <strong>Creation of Domain File:</strong> The <a href="https://rasa.com/docs/core/domains/">Domain</a> defines the universe of the chatbot in which it is going to operate. It defines intents, entities, slots and actions. It will also include templates for the things your bot can say.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/793fea670c12e0423bafbff57cd7f66d/href">https://medium.com/media/793fea670c12e0423bafbff57cd7f66d/href</a></iframe><p>· We are already familiar with Intent and entities because we had already defined in our data.json file. The only different is here just we are only mentioning the name of them. Under Intent, we will mention different intent are getting used during the conversations like greet, inform, goodbye, etc. and entities will be location.</p><p>· <a href="https://rasa.com/docs/core/slots/">Slots</a> are like memory of a bot. They act as a key-value store which can be used to store information the user provided (e.g their home city) as well as information gathered about the outside world (e.g. the result of a database query or an API call).</p><p>· For example, if your user has provided their <strong>home city</strong>, you might have a text slot called <strong>location</strong>. If the user asks for the weather, and you don’t know their <strong>home city</strong>, you will have to ask them for it. A text slot only tells Rasa Core whether the slot has a value. The specific value of a text slot (e.g. Bangalore or New York or Hong Kong) does not makes any difference.</p><p>· Utterance templates are the messages the bot will send back to the user. There are 2 ways to use them.</p><p>i. if the name of the template starts with utter_, the utterance can directly be used like an action. You would add the utterance template to the weather_domain.yml file. Afterwards, you can use these template as if it were an action in the stories.md file.</p><p>ii. You can use the templates to generate response messages from your custom actions using the dispatcher: dispatcher.utter_template(“utter_greet”). We will be using this in our actions.py file for custom template.</p><p>· <a href="https://rasa.com/docs/core/customactions/">Actions</a> are the things your bot runs in response to user input. There are three kinds of actions in Rasa Core:</p><p>i. default actions (action_listen, action_restart, action_default_fallback)</p><p>ii. utter actions, starting with utter_, which just sends a message to the user (see Bot Responses).</p><p>iii. custom actions — any other action, these actions can run arbitrary code</p><p>Here we have created class called ActionWeather and add as custom action using apixu website <a href="https://www.apixu.com/my/">https://www.apixu.com/my/</a> from where we are taking weather information.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75c694623258cc765a020512b7697a39/href">https://medium.com/media/75c694623258cc765a020512b7697a39/href</a></iframe><p><strong>Figure-6 actions.py file</strong></p><p><strong>3.</strong> <strong>Creation of Stories File:</strong></p><p>· A training example for the Rasa Core dialogue system is called <a href="https://rasa.com/docs/core/stories/#stories">a story</a>.</p><p>· A story starts with a name preceded by two hashes ## story_03248462. You can call the story anything you like, but it can be very useful for debugging to give them descriptive names.</p><p>· The end of a story is denoted by a newline, and then a new story starts again with ##.</p><p>· Messages sent by the user are shown as lines starting with * in the format intent{“entity1”: “value”, “entity2”: “value”}.</p><p>· Actions executed by the bot are shown as lines starting with — and contain the name of the action.</p><p>· Events returned by an action are on lines immediately after that action. For example, if an action returns a SetSlot event, this is shown as the line — slot{“slot_name”: “value”}</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/276bf47b90d79d3e324f7d27c841f281/href">https://medium.com/media/276bf47b90d79d3e324f7d27c841f281/href</a></iframe><p><strong>4.</strong> <strong>train_init and train_Online:</strong></p><p>· We are going to use weather_domain.yml and stories.md files to train our RASA Core dialogue model. Both the files paths have been mentioned in train_init.py file.</p><p>· Once training is completed, we are persisting or storing dialogue model related trained data into ‘./models/dialogue’ which will be used in train_online for execution.</p><p><strong>Command</strong>: python train_init.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11b05c27d149eeccb8e228c2c5d6affe/href">https://medium.com/media/11b05c27d149eeccb8e228c2c5d6affe/href</a></iframe><p>· Once the dialogue training model is generated, we will create train_online.py file for giving online training to the <a href="https://chatbotslife.com/">chatbot</a>.</p><p>· Here we are using ConsoleInputChannel libraries of RASA core which enables to train the chat bot through command prompt.</p><p>· We can train chatbot by making it understand whether the intent is correct, whether next action is correct and also if it is wrong then we can mention the correct intent and action so that chatbot will behave or act in this particular way. This all interaction can be stored into stories.md by choosing export.</p><p>· <strong>Command</strong>: python train_online.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7021211b6b199cae7ad7fda22c8c6303/href">https://medium.com/media/7021211b6b199cae7ad7fda22c8c6303/href</a></iframe><p><strong>5.</strong> <strong>Dialogue Management Model:</strong></p><p>· This allows user to chat with Weatherbot through command prompt.</p><p>· <strong>Command</strong>: python dialogue_management_model.py</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f09d43a9023acca39d9ebc19631dac2b/href">https://medium.com/media/f09d43a9023acca39d9ebc19631dac2b/href</a></iframe><p><strong>6.</strong> <strong>Understanding of important Keywords used in train_init, train_online and dialogue_management_model files:</strong></p><p>· The <a href="https://rasa.com/docs/core/api/agent/">agent</a> allows you to train a model, load, and use it. It is a simple API that lets you access most of Rasa Core’s functionality.</p><p>· Policy is the core model architecture. A Policy will define what is going to be the next action. We have used here 2 policies:</p><p>i. Memoization Policy which will copy our training data and remember them by heart and then predict the next action.</p><p>ii. Keras Policy uses Recurrent Neural Network (LSTM) which takes features to predict next possible action.</p><p>· Maxhistory determines the number of feature set that is needed to be fed to the neural network. In order for the network to provide an output, we will need to figure how much in the past of the conversation does the policy needs to look back in order to determine what to do next in a conversation. By default, Max History is set at 5. Memoization policy will look back 5 steps in tracker to determine if next step matches with any stories in your training data.</p><p>Augmentation Factor determines the number of stories to be glued together randomly. You can skip this by setting up as 0 upon training. By default, value of augmentation factor is 20.</p><p><strong>NOTE</strong>: For all the code I have added into this article are not aligned. Kindly refer to <a href="https://github.com/JustinaPetr/Weatherbot_Tutorial/"><strong>Github</strong></a> for actual code.</p><p><strong>Kindly let me know your feedback or input to make this article much better along with your claps and also, if you are facing any issue regarding creating of Weatherbot.</strong></p><h3>Don’t forget to give us your 👏 !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*ZxaGcKC3UQEydQIX" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e59ef%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e59ef&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e59ef%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href">https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href</a></iframe><figure><a href="https://chatbotslife.com/bot-communities-mastermind-group-d2dae9876709#.53x0py6ou"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*6XUspT9JOSq0w0Fi35HIaA.png" /></a></figure><figure><a href="https://m.me/ChatbotsLife"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*c1LDMH5vbnIz9rmAka8Hwg.png" /></a></figure><figure><a href="https://chatbotslife.com/chatbot-development-hire-top-ai-chatbot-developers-c8b45ef7f207"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*D0Jf3dI6ZThtqcfwDYY7mg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1dbd9b30b1e" width="1" height="1" alt=""><hr><p><a href="https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-2-e1dbd9b30b1e">Making of Chatbot using Rasa NLU &amp; Rasa Core-Part 2</a> was originally published in <a href="https://blog.chatbotslife.com/">Chatbots Life</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making of Chatbot using Rasa NLU & Rasa Core-Part 1]]></title>
            <link>https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-1-7138c438581f?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/7138c438581f</guid>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[rasa-nlu]]></category>
            <category><![CDATA[chatbots]]></category>
            <category><![CDATA[weather-bot]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Thu, 07 Nov 2019 13:41:50 GMT</pubDate>
            <atom:updated>2019-11-13T13:06:31.427Z</atom:updated>
            <content:encoded><![CDATA[<p>Kindly check for <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-1-7138c438581f"><strong>Part 1</strong></a>, <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-2-e1dbd9b30b1e"><strong>Part 2</strong></a> and <a href="https://medium.com/@mayurmorin/making-of-chatbot-using-rasa-nlu-rasa-core-part-3-ea836c1c3527"><strong>Part 3</strong></a> for complete chatbot execution.</p><p><strong>Who am I?</strong></p><p>Let’s divide the word ‘Chatbot’ and begins with <a href="https://techterms.com/definition/bot">Bot</a>. Well, the technical definition of bot states that it is a short form of robot and is an automated program that runs over the internet. Some bots run automatically while others only execute commands when they receive specific input.</p><p><a href="https://chatbotslife.com/">Chatbot</a> is one of the kind of bots which looks for certain text patterns in terms of input text or voice messages submitted by participants and respond back with automated action.</p><p>The chatbot can talk to you through different channels; such as Facebook Messenger, Siri, WeChat, Telegram, SMS, Slack, Skype and many others. Now a days, Amazon Alexa, Google Home and Microsoft Windows Cortana are few examples of chatbots which even respond with automated action and voice messages.</p><h3>Most Popular Chatbot Tutorials</h3><blockquote><a href="https://chatbotslife.com/aws-setup-for-deep-learning-fda04db6df75">1. AWS setup for Deep Learning</a></blockquote><blockquote><a href="https://chatbotslife.com/building-a-successful-chatbot-d210bec69773">2. Building a Successful Chatbot</a></blockquote><blockquote><a href="https://chatbotslife.com/how-to-integrate-api-ai-with-chatfuel-48baafd4613">3. How to Integrate API.AI with Chatfuel</a></blockquote><blockquote><a href="https://chatbotslife.com/build-a-working-sms-chat-bot-in-10-minutes-b8278d80cc7a">4. Build a working SMS chat-bot in 10 minutes</a></blockquote><p>It’s also very important to note that messaging applications are more being used by consumers than they spend time on social media. That’s the reason companies or business unit deliver chatbot experiences to consumers with messaging applications.</p><p><strong>Chatbot frameworks</strong></p><p>Many business entities are trying to make their own bots in the market, but when they choose to develop a bot, then they got confused between the platforms for chatbot development. There are plenty of chatbot platforms are available from which we can make chatbot, but it is difficult for business unit to decide.</p><p>Below mentioned are few <a href="https://chatbotsjournal.com/25-chatbot-platforms-a-comparative-table-aeefc932eaff">frameworks</a> which are being used to make chatbot:</p><p>1. IBM Watson Conversation</p><p>2. Microsoft Bot Framework</p><p>3. Dialogflow</p><p>4. Amazon Lex</p><p>5. ManyChat</p><p>6. RASA Stack</p><p>Today, we are going to discuss about RASA Stack chatbot framework.</p><p><strong>RASA Stack — A chatbot Solution</strong></p><p>The <a href="https://www.rasa.com/docs/get_started_step1/">Rasa Stack</a> is a pair of open source libraries (Rasa NLU and Rasa Core) that allow developers to expand chatbots and voice assistants beyond answering simple questions.</p><p>Using state-of-the-art machine learning, bots can hold contextual conversations with users. Rasa is production ready and used in large companies everywhere.</p><p><strong>Rasa NLU</strong>: A natural language understanding solution which takes the user input and tries to infer the intent and extract the available entities.</p><p><strong>Rasa Core</strong>: A dialogue management solution tries to build a probability model which decides the set of actions to perform based on the previous set of user inputs.</p><p>Rasa NLU’s job is to interpret messages, and Rasa Core’s job is to decide what should happen next.</p><p>Rasa NLU performs <em>Natural Language Understanding</em>, which means taking free-form text like <em>Please send the confirmation to </em><a href="/service/mailto:mayur@example.com"><em>mayur@example.com</em></a><em> </em>and turning it into structured data. Rasa Core performs <em>Dialog Management</em>, which means keeping track of a conversation, and deciding how to proceed. Both Rasa Core and NLU use Machine Learning to learn from real example conversations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*WpQ5lLDa-ReWJ025nBkpmA.png" /><figcaption><strong>Figure 1: Architecture of RASA Stack</strong></figcaption></figure><p>I have explained Weatherbot with Slack — Walk Through from <a href="https://jpboost.com/">Justina Petraitytė</a>’s blog From zero to hero: Creating a <a href="https://chatbotslife.com/">chatbot</a> with Rasa NLU and Rasa Core where she had explained in detail about creating weatherbot from scratch in approximately 2 hours of video with this <a href="https://jpboost.com/2018/02/06/creating-a-chatbot-with-rasa-nlu-and-rasa-core/">link</a>.</p><p>She has also provided GitHub link of the <a href="https://github.com/JustinaPetr/Weatherbot_Tutorial/">source code</a> for further reference.</p><p><strong>Weatherbot with Slack — Walk Through:</strong></p><p>We have understood the basic architecture of RASA stack. Let’s create a weatherbot with Slack as User Interface which will tell us the weather condition for a city.</p><p>Whenever we are going to give input text related to weather condition along with city name, then chatbot should understand the text and identify the city. This city should be passed to APIs and get the information of Temperature, Humidity, Wind Speed for that city.</p><p><strong>I have divided creation of weatherbot into 4 different levels along with their understanding.</strong></p><p><strong>LEVEL 1: </strong>Creating a simple program using RASA NLU to get an understanding of defining intent and entities.</p><p><strong>LEVEL 2:</strong> Creating an intermediate program using RASA Core and its dialogue management model where chatbot interacts at the command prompt level.</p><p><strong>LEVEL 3: </strong>Integrating RASA Core dialogue management model with Slack Messenger User Interface.</p><p><strong>LEVEL 4: </strong>Understanding Spacy and different algorithm underneath of RASA NLU and RASA Core.</p><p><strong>LEVEL 1: Creating a simple program using RASA NLU to get an understanding of defining intent and entities:</strong></p><p>1. <strong>Installation of Libraries</strong>: List out all the libraries required for creating chatbot in RASA NLU.</p><p>Create Requirements.txt file and put required libraries to be installed along with their version.</p><p><strong>Command</strong>: pip install -r requirements.txt</p><p>During the installation of libraries, multiple issues might occur due to operating system (Windows, Mac, Linux) compatibility settings and default system configuration.</p><p>For Example: C++ Compiler issue, NumPy version issue etc. It is good practice to google it out and find resolution so that complete installation of libraries is done.</p><p>2. <strong>Download Spacy</strong> Language Model to Parse text messages for extracting necessary information.</p><p><strong>Command:</strong> python -m spacy download en</p><p>3. <strong>Install npm and then RASA NLU Trainer</strong>.</p><p><strong>Command:</strong> npm i -g rasa-nlu-trainer</p><p>4.<strong> RASA NLU Trainer</strong> has cool UI which makes data generation of NLU model a lot easier. We can add any number of intent and text for data.json file which will be used for training the model. We need to do any action based on user input then we can define entity also by selecting relevant word.</p><p><strong>For Example</strong>: What’s the weather in <strong>Berlin</strong> now? Here, we need to <strong>highlight Berlin</strong> and give this entity a name like <strong>location</strong> so that next time onwards RASA NLU understands the same kind of context and mark other city name as location entity.</p><p>· How’z the weather in <strong>Ranchi</strong>?</p><p>· Can you please tell weather condition in <strong>Bengaluru</strong>?</p><p>Here, RASA NLU automatically interprets <strong>Ranchi</strong> and <strong>Bengaluru</strong> as location entity.</p><p><strong>Command:</strong> rasa-nlu-trainer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*3Fur1Gqh_nMWnCLLZXuFGA.png" /><figcaption><strong>Figure 2: rasa nlu trainer</strong></figcaption></figure><p>5. <strong>Creating Spacy_Config.json File</strong>: This file is required to be created as part of RASA NLU Configuration. The detailed explanation you can check at LEVEL 4. As of now, you need to understand that it helps to extract necessary information, provides path of data. json and storing generating nlu models’ files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84658b17ce398d4fc2c8a8e6676219b8/href">https://medium.com/media/84658b17ce398d4fc2c8a8e6676219b8/href</a></iframe><p><strong>Pipeline</strong> is going to define what features we are going to be used to crunch messages and extract necessary information. Details of Pipeline as explained Later.</p><p><strong>Path</strong> is directory where we will keep model after it is trained.</p><p><strong>Data</strong> is directory where data.json file which is created using rasa-nlu-trainer we are going to define intent and entities.</p><p><strong>6. RASA NLU TRAINER:</strong></p><p>· Creation of data.json file: Create a new empty data.json file with path of data/data.json.</p><p>· Open from rasa-nlu-trainer data.json file.</p><p>· Specify proper text, intent, entities.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/baddf8fce6d6342d15012ff3495835b8/href">https://medium.com/media/baddf8fce6d6342d15012ff3495835b8/href</a></iframe><p><strong>data.json</strong>: You can create this file manually first and then add the contents from rasa-nlu-trainer or manually also. This file is in json format which will have mainly Key-Value pair. The following terminology is mainly used in this file.</p><p>· <strong>text:</strong> User input is likely to be mentioned in this key.</p><p>· <strong>intent</strong>: It captures what bot should respond based on text. This can be further divided into few categories like greet, goodbye, inform, positive, negative, status, etc. If a user says, “<em>What’s the weather in Bengaluru</em>?”, the intent would be finding the details of weather in Bengaluru.</p><p>· <strong>Entity</strong>: The useful information from the user input can be extracted. From previous example, by intent we understand the aim is to find the day of week, but of which date? If we extract “<em>Bengaluru</em>” as the entity, we can perform the action on inform.</p><p><strong>7. Training the ML Model</strong>: In this step, the loaded Training Data is fed into an NLP pipeline and gets converted into an ML model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45e6a2d0e3217995a6e2830b9ecb0ace/href">https://medium.com/media/45e6a2d0e3217995a6e2830b9ecb0ace/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*pllpJzYaLR34StmtDL46SQ.png" /><figcaption><strong>Figure-4 Directory Structure</strong></figcaption></figure><p>· Now, it’s time for execution. We have already created data.json (./data/data.json) and spacy_config.json files. We are going to use these files to train our model and store this model related files into ‘./models/nlu’ folder.</p><p>· First, we need to run train_nlu(‘./data/data.json’,’config_spacy.json’,’./models/nlu’) function which persist or stores model information into mentioned path ‘./models/nlu’.</p><p>· Second, we need to comment train_nlu function and uncomment run_nlu() function and execute the python file as below mentioned given command line.</p><p>· Here in run_nlu function we have mentioned text message which RASA NLU interprets using data.json and spacy_config.json and it will return different intents along with their confidence level so that we will come to know that how RASA NLU calculates accuracy and confidence level.</p><p>· <strong>OUTPUT</strong>: Below mentioned output clearly explains when we have executed command python nlu_model.py with run_nlu() function. RASA NLU has tried to interpret text message “I am planning my holiday to Bercelona. I wonder what is the weather out there.” It calculates the confidence level with different intents which we had passed into data.json file.</p><p>o <strong>Inform</strong> intent has got highest accuracy with 73%.</p><p>o <strong>Greet </strong>intent has got 16% of confidence<strong>.</strong></p><p>o <strong>Goodbye</strong> intent has got 11% of accuracy.</p><p>· At the end, RASA NLU has classified intent as inform and value as bercelona and entity as location.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a7abcdf0750e9054b54943cf3ec82fa/href">https://medium.com/media/7a7abcdf0750e9054b54943cf3ec82fa/href</a></iframe><p><strong>Command</strong>: python nlu_model.py</p><p><strong>NOTE</strong>: For all the code I have added into this article are not aligned. Kindly refer to <a href="https://github.com/JustinaPetr/Weatherbot_Tutorial/"><strong>Github</strong></a> for actual code.</p><p><strong>Kindly let me know your feedback or input to make this article much better along with your claps and also, if you are facing any issue regarding creating of Weatherbot.</strong></p><h3>Don’t forget to give us your 👏 !</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*ZxaGcKC3UQEydQIX" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2F3e59ef%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2F3e59ef&amp;image=http%3A%2F%2Fapi.screenshotlayer.com%2Fapi%2Fcapture%3Faccess_key%3Dfe59908dad3baab69ffab249a2224b03%26viewport%3D1024x612%26width%3D1000%26url%3Dhttps%253A%252F%252Fupscri.be%252F3e59ef%253Fscreenshot&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href">https://medium.com/media/7078d8ad19192c4c53d3bf199468e4ab/href</a></iframe><figure><a href="https://chatbotslife.com/bot-communities-mastermind-group-d2dae9876709#.53x0py6ou"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*6XUspT9JOSq0w0Fi35HIaA.png" /></a></figure><figure><a href="https://m.me/ChatbotsLife"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*c1LDMH5vbnIz9rmAka8Hwg.png" /></a></figure><figure><a href="https://chatbotslife.com/chatbot-development-hire-top-ai-chatbot-developers-c8b45ef7f207"><img alt="" src="https://cdn-images-1.medium.com/max/255/1*D0Jf3dI6ZThtqcfwDYY7mg.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7138c438581f" width="1" height="1" alt=""><hr><p><a href="https://blog.chatbotslife.com/making-of-chatbot-using-rasa-nlu-rasa-core-part-1-7138c438581f">Making of Chatbot using Rasa NLU &amp; Rasa Core-Part 1</a> was originally published in <a href="https://blog.chatbotslife.com/">Chatbots Life</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NumPy (numpy.org) N-dimensional array for numerical computation]]></title>
            <link>https://medium.com/@mayurmorin/numpy-numpy-org-n-dimensional-array-for-numerical-computation-f74b9f197510?source=rss-257648bdd966------2</link>
            <guid isPermaLink="false">https://medium.com/p/f74b9f197510</guid>
            <category><![CDATA[numpy-interview-questions]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[numpy-cheatsheet]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[numpy]]></category>
            <dc:creator><![CDATA[Mayur Pethani]]></dc:creator>
            <pubDate>Sun, 25 Aug 2019 13:21:47 GMT</pubDate>
            <atom:updated>2019-08-25T13:21:47.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o653r9F-Ix_vIi2OTh5sDA.jpeg" /></figure><p><strong>NumPy </strong>contains a multi-dimentional array and matrix data structures. It can be utilised to perform a number of mathematical operations on arrays such as trigonometric, statistical and algebraic routines.</p><p>It is memory efficiency, meaning it can handle the vast amount of data more accessible than any other library. Besides, NumPy is very convenient to work with, especially for matrix multiplication and reshaping. On top of that, NumPy is fast. In fact, TensorFlow and Scikit learn to use NumPy array to compute the matrix multiplication in the back end</p><p>Let’s go through Numpy important features and functions. Also, based on few cheat sheets available on Numpy which, I have tried to articulate here, can be a guide to anyone who is new in the process of learning the python language as well as in the data science field.</p><p>Below mentioned libraries are very important and basics for learning and implementing projects on machine learning.</p><p>· <strong>NumPy </strong>(numpy.org) N-dimensional array for numerical computation</p><p>· <strong>SciPy </strong>(scipy.org) Scientific computing library for Python</p><p>· <strong>Matplotlib </strong>(matplotlib.org) 2D Plotting library for Python</p><p>· <strong>Pandas </strong>(pandas.pydata.org) Powerful Python data structures and data analysis toolkit</p><p>· <strong>Seaborn </strong>(seaborn.pydata.org) Statistical graphics library for Python</p><p>· <strong>Bokeh </strong>(bokeh.pydata.org) Interactive web visualization library</p><p>· <strong>Scikit-Learn</strong> (scikit-learn.org/stable) Python modules for machine learning and data mining</p><p>· <strong>NLTK</strong> (nltk.org) Natural language toolkit</p><p>· <strong>Jupyter Notebook</strong> (jupyter.org) Web app that allows you to create and share documents that contain live code, equations, visualizations and explanatory text</p><p>Although, the detailed descriptions and all the features and functions of Numpy library are available on <a href="https://www.numpy.org/">Numpy.org</a>, but the categorization of important functions and features of Numpy library, which we will be using on our day to day project implementation, can be as follows:</p><p>Just try to understand the categories and then under each categories which functions are available. Kindly also go through <a href="https://github.com/mayurmorin/Data-Science/blob/master/Numpy.py">gitHub</a> link here through which you will be able to download below mentioned all the features and functions in terms of numpy.py file. I have executed and prepared for my reference which you can use for your reference. You should be able to easily execute them using IDE like Jupyter Notebook, Pycharm, or Pyspyder.</p><p>Below are the list of features and functions of Numpy, but for better understanding you must execute all the functions which are mentioned below. You can download the file from <a href="https://github.com/mayurmorin/Data-Science/blob/master/Numpy.py">gitHub</a> and do the same.</p><h4><em>Creating Arrays</em></h4><pre><strong>import </strong>numpy <strong>as </strong>np<br><br>print(<strong>&quot;##########Creating Arrays ##########&quot;</strong>)<br><br>a = np.array([1,2,3])<br>b = np.array([(1.5,2,3),(4,5,6)],dtype=float)<br>c = np.array([[(1.5,2,3),(4,5,6)],[(3,2,3),(4,5,6)]],dtype= float)<br><br>print(<strong>&quot;1D Array a: &quot;</strong>,a)<br>print(<strong>&quot;2D Array b: &quot;</strong>,b)<br>print(<strong>&quot;2d Array c: &quot;</strong>,c)<br>print(<strong>&quot;##########Creating Arrays ##########\n&quot;</strong>)</pre><pre>print(<strong>&quot;##########Initial Placeholders##########&quot;</strong>)<br><br>print(<strong>&quot;Create an array of zeros&quot;</strong>)<br>print(np.zeros((3,4)))<br><br>print(<strong>&quot;Create an array of ones&quot;</strong>)<br>print(np.ones((2,3,4),dtype=int))<br><br>print(<strong>&quot;Create an array of evenly places values (step value)&quot;</strong>)<br>d = np.arange(10,25,5)<br>print(d)<br><br>print(<strong>&quot;Create an array of evenly places values (number of samples)&quot;</strong>)<br>print(np.linspace(0,2,9))<br><br>print(<strong>&quot;Create a constant array&quot;</strong>)<br>e = np.full((2,2),7)<br>print(e)<br><br>print(<strong>&quot;Create 2X2 identity matrix&quot;</strong>)<br>f = np.identity(2,dtype=int)<br>f1 = np.eye(2)<br>print(f,f1)<br><br>print(<strong>&quot;Create an array with random values&quot;</strong>)<br>print(<strong>&quot;2x2 Array of random floats between 0-1&quot;</strong>, np.random.random((2,2)))<br>print(<strong>&quot;6x7 Array of random floats between 0-100&quot;</strong>,np.random.rand(6,7)*100)<br>print(<strong>&quot;2x3 Array of random int between 0-4&quot;</strong>,np.random.randint(5,size=(2,3)))<br><br>print(<strong>&quot;Create an empty array&quot;</strong>)<br>print(np.empty((3,2)))<br><br>print(<strong>&quot;##########Initial Placeholders##########\n&quot;</strong>)</pre><h4><em>Importing and Exporting</em></h4><pre>print(<strong>&quot;##########Input/Output or IMPORTING/EXPORTING##########\n&quot;</strong>)<br><br>print(<strong>&quot;saving and loading on disk&quot;</strong>)<br>np.save(<strong>&#39;my_array&#39;</strong>,a)<br>np.savez(<strong>&#39;array.npz&#39;</strong>,a,b)<br>print(np.load(<strong>&#39;array.npz&#39;</strong>))<br>print(np.load(<strong>&#39;my_array.npy&#39;</strong>))<br><br>print(<strong>&quot;Saving and Loading TextFiles&quot;</strong>)<br>print(<strong>&quot;Loads an Array from Text File : &quot;</strong>, np.loadtxt(<strong>&quot;myfile.txt&quot;</strong>))<br>print(<strong>&quot;Loads an Array from CSV File : &quot;</strong>, np.genfromtxt(<strong>&quot;my_file.csv&quot;</strong>,delimiter=<strong>&quot;,&quot;</strong>))<br>print(<strong>&quot;Writes an Array to Text File : \n&quot;</strong>)<br>np.savetxt(<strong>&quot;myarray.txt&quot;</strong>,a,delimiter=<strong>&quot; &quot;</strong>)<br>print(<strong>&quot;Writes an Array to CSV File : \n&quot;</strong>)<br>np.savetxt(<strong>&quot;myarray.txt&quot;</strong>,a,delimiter=<strong>&quot;,&quot;</strong>)<br>print(np.loadtxt(<strong>&quot;myarray.txt&quot;</strong>))<br><br>print(<strong>&quot;##########Input/Output or IMPORTING/EXPORTING##########\n&quot;</strong>)</pre><h4><em>Copying/Sorting/Reshaping</em></h4><pre>print(<strong>&quot;##########Copying Arrays##########\n&quot;</strong>)<br>h=a.view()<br>print(<strong>&quot;Create a view of array with same data :&quot;</strong>, a, a.view())<br>print(<strong>&quot;Create a copy of array :&quot; </strong>, a, np.copy(a))<br>np.copy(a)<br>h=a.copy()<br>print(<strong>&quot;Create a deep copy of the array&quot;</strong>, a, a.copy())<br>print(<strong>&quot;##########Copying Arrays##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Sorting Arrays##########\n&quot;</strong>)<br>print(<strong>&quot;Sort an array : &quot;</strong>, a, a.sort())<br>print(<strong>&quot;Sort an element of any array&#39;s axis : &quot;</strong>, a, c.sort(axis=0))<br>print(<strong>&quot;##########Sorting Arrays##########\n&quot;</strong>)</pre><h4><em>Inspecting Properties</em></h4><pre>print(<strong>&quot;##########Data Types##########\n&quot;</strong>)<br><br>print(np.int64,np.float32,np.complex,np.bool,np.object,np.string_,np.unicode_)<br><br>print(<strong>&quot;####Inspecting Your Array: ####&quot;</strong>)<br>print(<strong>&quot;Array Dimensions: &quot;</strong>, a.shape)<br>print(<strong>&quot;Length of array: &quot;</strong>, len(a))<br>print(<strong>&quot;Number of array dimensions: &quot;</strong>, b.ndim)<br>print(<strong>&quot;Number of array elements: &quot;</strong>, e.size)<br>print(<strong>&quot;DataType of an array elements: &quot;</strong>, b.dtype)<br>print(<strong>&quot;Name of datatype: &quot;</strong>, b.dtype.name)<br>print(<strong>&quot;Convert an array to different type: &quot;</strong>, b.astype(int))<br>print(<strong>&quot;Asking for Help: &quot;</strong>, np.info(np.ndarray.dtype))<br><br>print(<strong>&quot;####Inspecting Your Array: ####&quot;</strong>)<br>print(<strong>&quot;##########Data Types##########\n&quot;</strong>)</pre><h4><em>Adding/Removing Elements</em></h4><pre>print(<strong>&quot;##########Array Mathematics##########\n&quot;</strong>)<br>print(<strong>&quot;##########Arithmatic Operations/SCALAR MATH######\n&quot;</strong>)<br><br>print(<strong>&quot;##########Substraction##########\n&quot;</strong>)<br>g = a - b<br>print(g)<br>print(np.subtract(a,b))<br>print(<strong>&quot;##########Substraction##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Addition##########\n&quot;</strong>)<br>print(b + a)<br>print(np.add(b,a))<br>print(<strong>&quot;##########Addition##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Division##########\n&quot;</strong>)<br>print(b/a)<br>print(np.divide(a,b))<br>print(<strong>&quot;##########Division##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Multiply##########\n&quot;</strong>)<br>print(a*b)<br>print(np.multiply(a,b))<br>print(<strong>&quot;##########Multiply##########\n&quot;</strong>)<br><br></pre><h4><em>Combining/Splitting</em></h4><pre>print(<strong>&quot;##########Adding and Removing Elements##########\n&quot;</strong>)<br>print(<strong>&quot;Return a new array with Shape (2,6)&quot;</strong>,h, h.resize((2,6),refcheck=<strong>False</strong>))<br><br>print(<strong>&quot;Append items to an array&quot;</strong>, h,g, np.append(h,g))<br>print(<strong>&quot;Insert items in an array&quot;</strong>, a, np.insert(a,1,5))<br>print(<strong>&quot;Delete items from an array&quot;</strong>, a, [1])<br><br>print(<strong>&quot;Combining Arrays&quot;</strong>)<br>print(<strong>&quot;Concatenate Arrays&quot;</strong>, a,d, np.concatenate((a,d),axis=0))<br>print(<strong>&quot;Stack arrays vertically (row-wise)&quot;</strong>,a,b, np.vstack((a,b)))<br>print(<strong>&quot;Stack arrays vertically (row-wise)&quot;</strong>,e,f, np.r_[e,f])<br><br>print(<strong>&quot;Stack arrays horizontally (column-wise)&quot;</strong>,a,b, np.hstack((e,f)))<br>print(<strong>&quot;Stack arrays horizontally (column-wise)&quot;</strong>,e,f, np.column_stack((a,d)))<br>print(<strong>&quot;Stack arrays horizontally (column-wise)&quot;</strong>,e,f, np.c_[a,d])<br><br>print(<strong>&quot;Splitting Arrays&quot;</strong>)<br>print(<strong>&quot;Split Array Horizontally at 3rd Index&quot;</strong>, a, np.hsplit(a,3))<br>print(<strong>&quot;Split Array Vertically at 2nd Index&quot;</strong>, c, np.vsplit(c,2))<br>print(<strong>&quot;##########Adding and Removing Elements##########\n&quot;</strong>)</pre><h4><em>Indexing/Slicing/Subseting</em></h4><pre>print(<strong>&quot;##########Subsetting, Slicing, and Indexing##########&quot;</strong>)<br><br>print(<strong>&quot;##########Subsetting##########\n&quot;</strong>)<br>print(<strong>&quot;Select element at 2nd Index&quot;</strong>, a, a[2])<br>print(<strong>&quot;Select element at row 1 column 2 &quot;</strong>, b, b[1,2])<br>print(<strong>&quot;##########Subsetting##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Slicing##########\n&quot;</strong>)<br>print(<strong>&quot;Select item at index 0 and item 1&quot;</strong>,a, a[0:2])<br>print(<strong>&quot;Select items at row 0 and 1 in column 1&quot;</strong>, b, b[0:2,1])<br>print(<strong>&quot;Select all items at row 0&quot;</strong>, b, b[:1])<br>print(<strong>&quot;Select all items at row 0&quot;</strong>, c, c[1,...], c[1,:,:])<br>print(<strong>&quot;Reverse Array&quot;</strong>, a, a[::-1])<br>print(<strong>&quot;##########Slicing##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Boolean Indexing##########\n&quot;</strong>)<br>print(<strong>&quot;Select elements from a less then 2 &quot;</strong>, a, a[a&lt;2])<br>print(<strong>&quot;##########Boolean Indexing##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Fancy Indexing##########\n&quot;</strong>)<br>print(<strong>&quot;Select elements (1,0), (0,1), (1,2), (0,0) &quot;</strong>, b, b[[1,0,1,0],[0,1,2,0]])<br>print(<strong>&quot;Select a subset of the matrix&#39;s rows and columns &quot;</strong>, b, b[[1,0,1,0]][:,[0,1,2,0]])<br>print(<strong>&quot;##########Fancy Indexing##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Array Manipulation##########\n&quot;</strong>)<br>print(<strong>&quot;Transposing Array&quot;</strong>)<br>i = np.transpose(b)<br>print(<strong>&quot;Permute Array Dimension&quot;</strong>,b, i, i.T)<br><br>print(<strong>&quot;Changing Array Shape&quot;</strong>)<br>print(<strong>&quot;Flatten Array&quot;</strong>, c, c.ravel())<br>print(<strong>&quot;Reshape but don&#39;t change data: &quot;</strong>, g, g.reshape(3,2))<br>print(<strong>&quot;##########Array Manipulation##########\n&quot;</strong>)<br><br>print(<strong>&quot;##########Subsetting, Slicing, and Indexing##########&quot;</strong>)</pre><h4><em>Scalar Math/Vector Math</em></h4><pre>print(<strong>&quot;##########Arithmatic Operations/VECTOR MATH######\n&quot;</strong>)<br>print(<strong>&quot;Exponentiation :&quot;</strong>, np.exp(b))<br>print(<strong>&quot;Square Root :&quot;</strong>, np.sqrt(b))<br>print(<strong>&quot;Print sines of an array :&quot;</strong>, b, np.sin(b))<br>print(<strong>&quot;Print cosines of an array :&quot; </strong>, b, np.cos(b))<br>print(<strong>&quot;Element wise natural logarithm :&quot;</strong>, b, np.log(b))<br>print(<strong>&quot;Dot Product : &quot;</strong>, e, f, e.dot(f))<br>print(<strong>&quot;[7*1+7*0 7*0+7*1&quot;<br>      &quot; 7*0+7*1 7*1+7*0]&quot;</strong>)<br>print(<strong>&quot;Absolute Value of each element in array: &quot;</strong>, np.abs(b))<br>print(<strong>&quot;Rounds up to the nearest int: &quot;</strong>, np.ceil(b))<br>print(<strong>&quot;Rounds down to the nearest int: &quot;</strong>, np.floor(b))<br>print(<strong>&quot;Rounds to the nearest int: &quot;</strong>, np.round(b))<br><br>print(<strong>&quot;##########Arithmatic Operations/VECTOR MATH######\n&quot;</strong>)</pre><h4><em>Statistics</em></h4><pre>print(<strong>&quot;##########Aggregate Functions/STATISTICS##########\n&quot;</strong>)<br>print(<strong>&quot;Array wise Summation :&quot; </strong>, a, a.sum())<br>print(<strong>&quot;Array wise minimum value :&quot; </strong>, a, a.min())<br>print(<strong>&quot;Return indices of the minimum values along the given axis of a :&quot; </strong>, a, a.argmin())<br>print(<strong>&quot;Maximum value of array row:&quot; </strong>, b, b.max(axis=0))<br>print(<strong>&quot;Cummulative sum of elements :&quot; </strong>, b, b.cumsum(axis=1))<br>print(<strong>&quot;Mean :&quot;</strong>, a, a.mean())<br>print(<strong>&quot;Median :&quot;</strong>, b, np.median(b))<br>print(<strong>&quot;Pearson product-moment Correlation Coefficiant&quot;</strong>, [1,2,3], b, np.corrcoef([1,2,3],b))<br>print(<strong>&quot;Variance of an array :&quot; </strong>, np.var(b))<br>print(<strong>&quot;Standard Deviation of an array :&quot; </strong>, np.std(b,axis=1))<br>print(<strong>&quot;##########Aggregate Functions/STATISTICS##########\n&quot;</strong>)</pre><p>Once you have executed above mentioned Numpy functions, you will be pretty much confident to apply the same in your day to day projects.</p><p>Below are few references which also you can explore for learning Numpy which I had found very useful during my investigation.</p><p><strong><em>NOTE: There are many more features and functions are available in Numpy library apart from mentioned above. You can refer Numpy.org for the same.</em></strong></p><h4>[1.] <a href="https://towardsdatascience.com/first-step-in-data-science-with-python-numpy-5e99d6821953">First step in Data Science with Python — NumPy</a></h4><h4>[2.] <a href="https://towardsdatascience.com/a-hitchhiker-guide-to-python-numpy-arrays-9358de570121">A hitchhiker guide to python NumPy Arrays</a></h4><h4>[3.] <a href="https://towardsdatascience.com/hitchhiker-tips-on-effectively-using-python-numpy-arrays-66649b7bd5fb">Effectively using Python NumPy Arrays</a></h4><h4>[4.] <a href="https://www.machinelearningplus.com/python/101-numpy-exercises-python/">101 NumPy Exercises for Data Analysis</a></h4><h4>[5.] <a href="https://medium.com/fintechexplained/why-should-we-use-numpy-c14a4fb03ee9">Why Should We Use NumPy?</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f74b9f197510" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>