<?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 Anshuman Ranjan on Medium]]></title>
        <description><![CDATA[Stories by Anshuman Ranjan on Medium]]></description>
        <link>https://medium.com/@anshuman-ranjan01?source=rss-911433833d00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8KYdeurCFNyND2-r</url>
            <title>Stories by Anshuman Ranjan on Medium</title>
            <link>https://medium.com/@anshuman-ranjan01?source=rss-911433833d00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 03:06:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anshuman-ranjan01/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[How to clear AWS Certified Machine Learning Specialty : My Fast-track strategy]]></title>
            <link>https://anshuman-ranjan01.medium.com/how-to-clear-aws-certified-machine-learning-specialty-my-fast-track-strategy-92530fca43c4?source=rss-911433833d00------2</link>
            <guid isPermaLink="false">https://medium.com/p/92530fca43c4</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ml-specialty]]></category>
            <category><![CDATA[aws-speciality]]></category>
            <category><![CDATA[machinelearningcertifi]]></category>
            <category><![CDATA[aws-certification]]></category>
            <dc:creator><![CDATA[Anshuman Ranjan]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 09:16:55 GMT</pubDate>
            <atom:updated>2021-04-25T09:16:55.379Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to clear AWS Certified Machine Learning Specialty : My Fast-track strategy</h3><p>AWS <a href="https://aws.amazon.com/certification/certified-machine-learning-specialty/">certified-machine-learning-specialty</a> is one of the specialty exams offered by AWS which covers AWS AI/ML offerings in AWS cloud</p><p>I would create another detailed Story on detailed steps on preparation if you have a 3–4 months plan to appear in this exam , this below steps are for someone with 2–3 weeks timeline to give the exam</p><p>This Story covers a fast track strategy on how to prepare and pass the exam in least amount of time by studying smart . Before you start since this is a fast track there are per-requisite and hence make sure you have these before using my advice for preparation</p><h3><strong>Pre-Requisite</strong></h3><p><strong>a)</strong> You have a working AWS background . (Not Theoretical but Practical ) which means you have worked on AWS cloud using multiple core services like IAM , S3 , EC2 , VPC etc . If you are new to AWS or have just started I would recommend focusing our preparation on Entry level AWS certifications like <a href="https://aws.amazon.com/certification/certified-solutions-architect-associate/">certified-solutions-architect-associate</a> which covers all AWS services used in common projects and tests your ability to design/correct/fit Services in projects .</p><p><strong>b)</strong> You have a data science background or have worked in ML project before / have theoretical knowledge in Stats / ML using R/Python either in college or in work . This is required so that you can focus on the key areas required for exam more</p><p><strong>c)</strong> Security / Storage . Ideally with some AWS background you do have a understanding of various storage solutions as well as how security is implemented on AWS , understanding of core IAM / Policy / Networking between services using VPC / PrivateLink would require good solid understand before you start prep for any Specialty exam . Security is a prime focus on all AWS exams</p><p><strong>d)</strong> You have been using/used Sagemaker Service on a medium-Intermediate level understanding . (This is the most important Service for exam)</p><p>Ok , it seems you reached this far , so I am assuming you do have per-requisites . So lets begin :</p><p>Step 1: Go to AWS training website , give the sample test paper available here : (<a href="https://d1.awsstatic.com/training-and-certification/docs-ml/AWS%20Certified%20Machine%20Learning%20-%20Specialty_Sample%20Questions.pdf">SamplePaper</a>)</p><p>With background in ML and AWS you should at least be expecting 40–50% correct answers in above (at-least that’s what I got)</p><p>Step 2 : Review answers on the paper and see which area did you miss out of was it ML Stats / Sagemaker / AI ?</p><p>Step 3: Now here is an important step , book the test slot so that you have a time target , Ml is a wide area and it is easy to get stuck in a rabbithole , it is important to have a date+time+money locked in to be able to focus . Don’t worry you can reschedule your exam for free 24 hours before the timeslot , but paying and booking a slot provides a timeline</p><p>Step 4: Assuming you have a background in ML Stats , take this AWS FREE Training “<a href="https://www.aws.training/Details/eLearning?id=26598">Elements of Data Science</a>” . This a a fast tracked ML Stats training which will feel fast going but will cover almost all important areas you should know for the Stats part of exam .Take notes in a summary Notebook that you would maintain till end ,which will also be used for last minute revision . Try to take notes on sections of this training which you have not heard of before or are not very familiar with (Example I was not familiar with Data Leakage )</p><p>Step 5:Sagemaker is heavy service for this exam , give it a good end to end read on its documentation, don’t skip anything . While reading make sure you note down important points like Inputs/Output/Important Hyper parameter/ObjectiveMetrics for “ALL” algorithms .</p><p>Step 6: Use this github link (<a href="https://github.com/aws/amazon-sagemaker-examples/tree/master/introduction_to_amazon_algorithms">https://github.com/aws/amazon-sagemaker-examples/tree/master/introduction_to_amazon_algorithms</a>) spin up a SM notebook / Jupyter notebook in your Laptop and run “ALL” the algorithms to make sure you understand thier usecase / Input output / optimizations etc</p><p>Step 7: Give a good read on the AWS Whitepapers</p><ol><li><a href="https://d1.awsstatic.com/whitepapers/aws-power-ml-at-scale.pdf">Power Machine Learning at Scale</a></li><li><a href="https://d1.awsstatic.com/whitepapers/aws-managing-ml-projects.pdf">Managing Machine Learning Projects</a></li><li><a href="https://d1.awsstatic.com/whitepapers/machine-learning-foundations.pdf">Machine Learning Foundations: Evolution of ML and AI</a></li><li><a href="https://d1.awsstatic.com/whitepapers/augmented-ai-the-power-of-human-and-machine.pdf">Augmented AI: The Power of Human and Machine</a></li><li><a href="https://docs.aws.amazon.com/wellarchitected/latest/machine-learning-lens/wellarchitected-machine-learning-lens.pdf">Machine Learning Lens — AWS Well-Architected Framework</a></li></ol><p>Step 8: Now that you have 50% work done , take some sample test to analyze which areas require more preparation . Before sitting on any Sample tests like (Udamy/ TutorialDojo/ Whizlabs) take a read on AI services in AWS like Lex/Polly/Translate/Transcribe/Rekognition . These AI services will be featured in exam</p><p>Step 7 : Important to remember the Sample tests available online Free/paid are not true representation of exam , I would say they are 20–30% easier than the actual exam .The reason for taking test at Step 6 is to understand the question types , and HOW to answer them , for example what does CHEAPER solution mean or what does Serverless solution mean and how would that affect the answer selection .Also the sample test gives you a idea/practice on reading the important details of questions .You will notice all questions have parts of sentence that would be twisted to confuse you like :<br>1. Which one would be the least overhead solution</p><p>2. Which one is the most cost effective solution</p><p>3.Which one would required least maintenance overhead</p><p>4.Which one is the fastest solution to implement</p><p>Step 8 : Review all answers in Sample tests and keep in mind the caviates on questions that you answered incorrectly as that learning would help in the actual exam .If possible note down the question/Notes on areas that you did not know about or prepared . In my case it was Kinesis Analytics Stream(had not used it before in my work)</p><p>Step 9 : You would have seen practice questions from below Services : Glue , EMR , Kinesis , S3 , IAM , VPC , Elasticsearch + All AI services + Sagemaker .All these services are must know and require you to understand how they work and all the available options they provide , it is important to see them in action , hence I would recommend doing a sample run through in all components , also trying to create a dummy resource through console will make it stay in your mind</p><p>Step 10 : If you do not have an AWS account to play with use the free trial account , another option is to take a course in Udamy /ACloudGuru .These courses are 6–8 hour long and will take you through a fast ride across all services . Use these resources as your base and don’t rely on only them</p><p>Step 11 : Now that you have gone through above 10 steps here is the key part . Take this FREE AWS provided training : <a href="https://www.aws.training/Details/eLearning?id=42183">Exam Readiness: AWS Certified Machine Learning — Specialty</a> . This training covers all the section again in fast pace and lets you give a 30 question test in the end . The questions on this test are at the same difficulty level as actual exam. You should be aiming to get 90%+ correct here to proceed</p><p>Step 12 : On Exam day , review your notes / review questions that you answered incorrectly and what you learned from them .Keep calm</p><p>Hit a clap if you like /Passed your exam :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92530fca43c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Cleaning in Natural Language Processing]]></title>
            <link>https://medium.com/analytics-vidhya/data-cleaning-in-natural-language-processing-1f77ec1f6406?source=rss-911433833d00------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f77ec1f6406</guid>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[nlp]]></category>
            <dc:creator><![CDATA[Anshuman Ranjan]]></dc:creator>
            <pubDate>Sat, 07 Mar 2020 16:15:29 GMT</pubDate>
            <atom:updated>2020-04-29T17:12:21.721Z</atom:updated>
            <content:encoded><![CDATA[<p>The post will go through basic of NLP data processing . We would go through the most popular libraries used for data cleaning in NLP space and provide code for reusing in your project</p><p>For this post I am going to use a the google News dataset (<a href="https://www.kaggle.com/therohk/million-headlines#abcnews-date-text.csv">Download</a>) which is a csv file with two columns :</p><ul><li><strong>publish_date</strong></li><li><strong>headline_text</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JCY04wRUJ7KKrI_w3uEdHw.png" /></figure><p>There are various applications to the data like</p><ul><li>Creating word2vec models (Google word2vec trained model on 100 billion words ) [<a href="https://code.google.com/archive/p/word2vec/">LINK</a>]</li><li>Creating Trading Systems to classify good/bad sentiments</li></ul><p>What all the applications have in common is data cleaning , usually the raw data over a properly or improperly formed sentence is not always desirable as it contains lot of unwanted components like null/html/links/url/emoji/stopwords etc . In this blog I am going to go through the most commonly used data processing that is used to clean Natural language text</p><h3><strong>Fixing null values</strong></h3><p>The most common and the first thing you should check is null values , there are various tool for doing that .</p><p>First we start with a basic overview of how many null values are we dealing with . This can be found out by running :</p><pre>train.isnull().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i-FOhgy8xqNcB4BXoSsowA.png" /><figcaption>(Note: Actual dataset used in this blog does not have any null , this is only for demonstration)</figcaption></figure><p>The above gives you a overview into how many nulls are you dealing with in each column of the pandas dataframe .</p><p>Next step is to either define a value to replace or remove the null values in the dataset , to remove and create a new dataframe of not null values you can use the below code :</p><pre>train[pd.notnull(train[&quot;headline_text&quot;])]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CHAP6AKSC4jxxyOsoPDMkg.png" /><figcaption>This provides you with a dataframe without null headline_text</figcaption></figure><p>You can also decide to replace the null values to something that makes sense for your algorithms so for instance in my case I want to make all headline_text have text as “IGNORE TEXT” where there is no values . I can do that using the .fillna() method in pandas:</p><pre>train.headline_text.fillna(&quot;IGNORE TEXT&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qse-rb5Al_65d4HV8ntoyg.png" /></figure><p>Another popular tool in pandas library is .dropna() which is very useful with Null/NaN/NaT values .It is very customizable with its arguments</p><pre>train.dropna(axis=0, how=&quot;any&quot;, thresh=None, subset=None, inplace=False).shape</pre><ul><li>axis=0/1 , 0 means drop rows and 1 means drop columns</li><li>how=all/any , all means if all values are null , any means if even a single value is null</li><li>thresh= threshold of how many to drop at max</li><li>subset = range of row columns to scan</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBWOL06Z_EsGBvTVBH-FTw.png" /><figcaption>Notice how 2 rows got dropped b the dropna() function from dataframe as they had null values</figcaption></figure><h3>Removing URL</h3><pre>def remove_URL(headline_text):<br>    url = re.compile(r&#39;https?://\S+|www\.\S+&#39;)<br>    return url.sub(r&#39;&#39;, headline_text)</pre><p>Use the above function to remove any url(https://medium.com/starting%20with%20https://%20www.%20from%20the%20text%C2%A0)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E43q0cWrBPAiiFPr4LBsnQ.png" /><figcaption>Notice how the url is removed using the .apply()</figcaption></figure><h3><strong>Removing HTML tags</strong></h3><p>You can use the below function to remove the html tags using regex</p><pre>def remove_html(headline_text):<br>    html=re.compile(r&#39;&lt;.*?&gt;&#39;)<br>    return html.sub(r&#39;&#39;,headline_text)<br><br>train[&#39;headline_text&#39;] = train[&#39;headline_text&#39;].apply(remove_html)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qc38Sv2v-6q4yQjtwXB6Fg.png" /><figcaption>Notice how the HTML tags were removed from the text</figcaption></figure><h3>Removing Pictures/Tags/Symbols/Emojis</h3><p>Often dealing with real world free text you would find your text to contain lot of smiley,emoji,picture etc based on platform that you get your dataset from . these require us to have a function that can filter out these special character sequence</p><pre>def remove_emojis(data):<br>    emoj = re.compile(&quot;[&quot;<br>        u&quot;\U0001F600-\U0001F64F&quot;  # emoticons<br>        u&quot;\U0001F300-\U0001F5FF&quot;  # symbols &amp; pictographs<br>        u&quot;\U0001F680-\U0001F6FF&quot;  # transport &amp; map symbols<br>        u&quot;\U0001F1E0-\U0001F1FF&quot;  # flags (iOS)<br>        u&quot;\U00002500-\U00002BEF&quot;  # chinese char<br>        u&quot;\U00002702-\U000027B0&quot;<br>        u&quot;\U00002702-\U000027B0&quot;<br>        u&quot;\U000024C2-\U0001F251&quot;<br>        u&quot;\U0001f926-\U0001f937&quot;<br>        u&quot;\U00010000-\U0010ffff&quot;<br>        u&quot;\u2640-\u2642&quot; <br>        u&quot;\u2600-\u2B55&quot;<br>        u&quot;\u200d&quot;<br>        u&quot;\u23cf&quot;<br>        u&quot;\u23e9&quot;<br>        u&quot;\u231a&quot;<br>        u&quot;\ufe0f&quot;  # dingbats<br>        u&quot;\u3030&quot;<br>                      &quot;]+&quot;, re.UNICODE)<br>    return re.sub(emoj, &#39;&#39;, data)</pre><pre>train[&#39;headline_text&#39;] = train[&#39;headline_text&#39;].apply(remove_emoji)</pre><h3>Removing Punctuation</h3><p>For cleaning on English language often punctuation occur as part of free text which do not add value usually to your model , they can be remove them from our dataset using below function</p><pre>def remove_punct(headline_text):<br>    table=str.maketrans(&#39;&#39;,&#39;&#39;,string.punctuation)<br>    return headline_text.translate(table)</pre><pre>train[&#39;headline_text&#39;] = train[&#39;headline_text&#39;].apply(remove_punct)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeE_hM24y4TMuMXhWui_Fw.png" /><figcaption>Notice how () are removed from the text</figcaption></figure><h3>Text Tokenizing</h3><p>Next useful step in most of usecase is to extract the text from the sentence , usually there are multiple possibility , here below we are using one of the most popular library <a href="https://www.nltk.org/">nlkt</a> which stands of natural language toolkilk library</p><pre>import nltk.data</pre><pre>##Load language Specific .pickle file</pre><pre>tokenizer = nltk.data.load(&#39;tokenizers/punkt/PY3/english.pickle&#39;)<br>spanish_tokenizer = nltk.data.load(&#39;tokenizers/punkt/PY3/spanish.pickle&#39;)</pre><pre>##Different type of tokenizer</pre><pre>from nltk.tokenize import regexp_tokenize <br>from nltk.tokenize import RegexpTokenizer <br>from nltk.tokenize import WordPunctTokenizer <br>from nltk.tokenize import PunktWordTokenizer <br>from nltk.tokenize import TreebankWordTokenizer <br>from nltk.tokenize import word_tokenize</pre><pre>##Sample initialization of token </pre><pre>tokenizer = nltk.tokenize.RegexpTokenizer(r&#39;\w+&#39;)</pre><pre>##Define Normalization <br>normalization = None<br>normalization = &#39;stemmer&#39;<br>normalization = &#39;lemmatizer&#39;</pre><pre>##Define Vectorizer <br>vectorizer = &#39;countvectorizer&#39;<br>vectorizer = &#39;tfidfvectorizer&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*e8uentcFh-Cz0IV6eV2VBA.png" /><figcaption>Notice how the sentence gets converted to text tokens</figcaption></figure><h3>Normalization</h3><p>A common preprocessing step when clearing social media text is normalization. Text normalization is the process of transforming a text into a canonical (standard) form. For example, the word “gooood” and “gud” can be transformed to “good”, its canonical form.</p><p><a href="https://www.kdnuggets.com/2019/04/text-preprocessing-nlp-machine-learning.html">Ref - I</a></p><p>Example :</p><p>2moro,2mrrw,tomrw → tomorrow</p><p>b4 → before</p><p>In python this can be done using nltk library</p><pre>def stem_tokens(tokens):<br>    stemmer = nltk.stem.PorterStemmer()<br>    tokens = [stemmer.stem(token) for token in tokens]<br>    return tokens</pre><pre>def lemmatize_tokens(tokens):<br>    lemmatizer = nltk.stem.WordNetLemmatizer()<br>    tokens = [lemmatizer.lemmatize(token) for token in tokens]<br>    return tokens</pre><pre>def normalize_tokens(normalization):<br>    if normalization is not None:<br>        if normalization == &#39;stemmer&#39;:<br>            train[&#39;text&#39;] = train[&#39;text&#39;].apply(stem_tokens)<br>        elif normalization == &#39;lemmatizer&#39;:<br>            train[&#39;text&#39;] = train[&#39;text&#39;].apply(lemmatize_tokens)<br>        <br>normalize_tokens(normalization)</pre><h3>Stopwords</h3><p>In English language you would usually need to remove all the un-necessary stopwords , the nlkt library contains a bag of stopwords that can be used to filter out the stopwords in a text . The list can be seen by code below</p><pre>import nltk<br>from nltk.corpus import stopwords<br> set(stopwords.words(&#39;english&#39;))</pre><p>{‘ourselves’, ‘hers’, ‘between’, ‘yourself’, ‘but’, ‘again’, ‘there’, ‘about’, ‘once’, ‘during’, ‘out’, ‘very’, ‘having’, ‘with’, ‘they’, ‘own’, ‘an’, ‘be’, ‘some’, ‘for’, ‘do’, ‘its’, ‘yours’, ‘such’, ‘into’, ‘of’, ‘most’, ‘itself’, ‘other’, ‘off’, ‘is’, ‘s’, ‘am’, ‘or’, ‘who’, ‘as’, ‘from’, ‘him’, ‘each’, ‘the’, ‘themselves’, ‘until’, ‘below’, ‘are’, ‘we’, ‘these’, ‘your’, ‘his’, ‘through’, ‘don’, ‘nor’, ‘me’, ‘were’, ‘her’, ‘more’, ‘himself’, ‘this’, ‘down’, ‘should’, ‘our’, ‘their’, ‘while’, ‘above’, ‘both’, ‘up’, ‘to’, ‘ours’, ‘had’, ‘she’, ‘all’, ‘no’, ‘when’, ‘at’, ‘any’, ‘before’, ‘them’, ‘same’, ‘and’, ‘been’, ‘have’, ‘in’, ‘will’, ‘on’, ‘does’, ‘yourselves’, ‘then’, ‘that’, ‘because’, ‘what’, ‘over’, ‘why’, ‘so’, ‘can’, ‘did’, ‘not’, ‘now’, ‘under’, ‘he’, ‘you’, ‘herself’, ‘has’, ‘just’, ‘where’, ‘too’, ‘only’, ‘myself’, ‘which’, ‘those’, ‘i’, ‘after’, ‘few’, ‘whom’, ‘t’, ‘being’, ‘if’, ‘theirs’, ‘my’, ‘against’, ‘a’, ‘by’, ‘doing’, ‘it’, ‘how’, ‘further’, ‘was’, ‘here’, ‘than’}</p><pre>def remove_stopwords(text):<br>    words = [w for w in text if w not in stopwords.words(&#39;english&#39;)]<br>    return wordstrain[&#39;headline_text&#39;] = train[&#39;headline_text&#39;].apply(remove_stopwords)</pre><p>Example data input :</p><pre>Input : [&#39;This&#39;, &#39;is&#39;, &#39;a&#39;, &#39;sample&#39;, &#39;sentence&#39;, &#39;,&#39;, &#39;showing&#39;, <br>&#39;off&#39;, &#39;the&#39;, &#39;stop&#39;, &#39;words&#39;, &#39;filtration&#39;, &#39;.&#39;]<br></pre><pre>Output : [&#39;This&#39;, &#39;sample&#39;, &#39;sentence&#39;, &#39;,&#39;, &#39;showing&#39;, &#39;stop&#39;,<br>&#39;words&#39;, &#39;filtration&#39;, &#39;.&#39;]</pre><h3>Vectorizing your code</h3><p>The <a href="https://scikit-learn.org/stable/modules/classes.html#module-sklearn.feature_extraction">sklearn.feature_extraction</a> module can be used to extract features in a format supported by machine learning algorithms from datasets consisting of formats such as text and image</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C32OakrZxsXvyeat5Yf_sw.png" /><figcaption>Based on your usecase you would need to selelct the ngram to create a feature vector</figcaption></figure><pre>## Default CountVectorizer</pre><pre>from sklearn.feature_extraction.text import CountVectorizer<br>corpus = [<br>    &#39;This is the first document.&#39;,<br>    &#39;This document is the second document.&#39;,<br>    &#39;And this is the third one.&#39;,<br>    &#39;Is this the first document?&#39;,<br>]<br>vectorizer = CountVectorizer()<br>X = vectorizer.fit_transform(corpus)<br>print(vectorizer2.get_feature_names())<br>print(X.toarray())</pre><p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><pre>## CountVectorizer(with ngram=2)</pre><pre>vectorizer2 = CountVectorizer(analyzer=&#39;word&#39;, ngram_range=(2, 2))<br>X2 = vectorizer2.fit_transform(corpus)<br>print(vectorizer2.get_feature_names())<br>print(X2.toarray())</pre><p>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Usage in real life :</p><pre># Vectorizationin funcation<br>def vectorize(vectorizer):<br>    if vectorizer == &#39;countvectorizer&#39;:<br>        print(&#39;countvectorizer&#39;)<br>        vectorizer = CountVectorizer()<br>        train_vectors = vectorizer.fit_transform(train[&#39;text&#39;])<br>        test_vectors = vectorizer.transform(test[&#39;text&#39;])<br>    elif vectorizer == &#39;tfidfvectorizer&#39;:<br>        print(&#39;tfidfvectorizer&#39;)<br>        vectorizer = TfidfVectorizer(min_df=2, max_df=0.5, ngram_range=(1, 2))<br>        train_vectors = vectorizer.fit_transform(train[&#39;text&#39;])<br>        test_vectors = vectorizer.transform(test[&#39;text&#39;])<br>    return train_vectors, test_vectors<br>train_vectors, test_vectors = vectorize(vectorizer)</pre><p>Hope the above compilation helps a beginner with 1 st steps into NLP</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f77ec1f6406" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/data-cleaning-in-natural-language-processing-1f77ec1f6406">Data Cleaning in Natural Language Processing</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>