<?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 Ridham Dave on Medium]]></title>
        <description><![CDATA[Stories by Ridham Dave on Medium]]></description>
        <link>https://medium.com/@ridhamdave5?source=rss-ad3f4f8773ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zgh6EiHtVzyq13ii</url>
            <title>Stories by Ridham Dave on Medium</title>
            <link>https://medium.com/@ridhamdave5?source=rss-ad3f4f8773ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:33:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ridhamdave5/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[Create your Professional/Educational resume using LaTeX]]></title>
            <link>https://medium.com/data-science/create-your-professional-educational-resume-using-latex-7bc371f201e3?source=rss-ad3f4f8773ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/7bc371f201e3</guid>
            <category><![CDATA[resume]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Ridham Dave]]></dc:creator>
            <pubDate>Tue, 24 Sep 2019 04:31:53 GMT</pubDate>
            <atom:updated>2019-12-05T03:54:01.247Z</atom:updated>
            <content:encoded><![CDATA[<p>A resume can be considered your first impression in front of your employer. A resume is the most suitable means of announcing your claim that you are the perfect choice for the position to your prospects employer. In this tutorial, I would like to demonstrate the use of the LaTeX environment to create a well organized and professional resume for your future endeavors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*1juNtGlXawaTr7NB8c5oeA.png" /></figure><p>The primary motive behind a compelling resume is to showcase your essential assets like your Qualifications, Experience, Achievements, Capabilities, and Qualities. Based on the typical mentality of hiring managers(employers), it has been observed that the employer takes just a few seconds to decide whether to call the person for the interview or not. As commonly experienced in the corporate world, the scenario, of a person with the necessary skills and appropriate experience not getting the interview call, is observed frequently. This is because the person applying for the job has failed to advertise himself clearly in the resume.</p><p>Hence, to prepare a compelling resume, a certain standard should be followed in the professional ecosystem. Following a predefined rule does not imply that a specific format should be followed in each application/resume. Each resume can be different from the another based on the applicant’s way of representing himself/herself, to the employer. A resume is a way of portraying a professional/educational profile effectively to compel the scrutineer.</p><p>Using a general-purpose text editor like Microsoft Word or Google Docs can serve the preliminary purpose of maintaining draft copies of your resume. These editors maintain the “what you see is what you get” approach to format the work. However, it takes plenty of unnecessary efforts to follow a particular formatting/editing standard throughout the resume using such an editor. Due to such issues, it motivates me to introduce the <a href="https://www.latex-project.org/">LaTeX environment</a> to the reader. LaTeX is a document preparation system used by academic and research communities for the publication of their work. Specifically, the writer uses markup tagging conventions to stylize text throughout a document, add citations and cross-references, and to define the structure of the document. LaTeX uses a TeX distribution such as <a href="https://www.tug.org/texlive/">TeX Live</a> or <a href="https://miktex.org/">MikTeX </a>to produce an output file (PDF) suitable for printing or digital distribution.</p><p>Preparing a resume in LaTeX can decrease the overall complexity required for formatting the document; hence, it is utmost necessary for every professional to know the basic LaTeX syntax for resume building. In this tutorial, I would cover several aspects for creating a powerful and effective resume which would cover mostly each element of an application.</p><p>To begin with, each LaTeX file can contain a specific Style Class file commonly know as <strong><em>.cls </em></strong>which defines all the styling rules for the documents. This class file function similar to the CSS files in web designing. Multiple class files are readily available on the web for resume building, out of which I prefer the file provided by <a href="https://github.com/treyhunner/resume/blob/master/resume.cls">Trey Hunner</a> for styling. This file is a simple yet effective way to represent your self. Download the class file from the link provided below:</p><blockquote><a href="https://github.com/ridhamdave/resume-latex/blob/master/resume.cls">ridhamdave/resume-latex/blob/master/resume.cls</a></blockquote><p>Each LaTeX file start and ends as a “document” object. For demonstration:</p><pre>\documentclass{resume} % The style class<br>\begin{document}<br>.<br>.<br>.<br>\end{document}</pre><p>Let’s start creating the resume, where the first task is to provide the personal details on top of the page, which is also known as the Address section. This section will be present on top of the document containing detailed information regarding your name, address, phone number, and e-mail address. Here the provided class file defines certain tags(markups) for the title and other contact information. Add this line before the document beginning to reflect the introduction section.</p><pre>\name{John Snow} % Your name<br>\address{North of the Wall, Outside the reach of every kingdom} <br>\address{(+0)9999999999 \\ <a href="/service/mailto:johnsnow@realnorth.com">johnsnow@realnorth.com</a>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8ZVVL0sxJ0T9VS7CYM80A.png" /><figcaption>Introduction Section above the first page</figcaption></figure><p>The next section is the most important for every fresher coming out of a college, i.e., the educational background. This section must cover the degree perused, educational institute, its affiliated university, and the overall CGPA/marks. This class file provides a predefined “rSection” tag for differentiating each section of your resume. The curly braces for the part contain the section’s name, and the entries between the \begin and \end represent actual content required.</p><p>Here, \bf represents <strong>Bold</strong>, while \em represents <em>italics </em>and \hfill command is used to provide appropriate formatting space between the right and side of the page. The Education section is as provided below, which is entered inside the actual document:</p><pre>\begin{rSection}{Education}</pre><pre>{\bf Massachusetts Institute of Technology, Cambridge} \hfill {\em July 2016 - May 2020} <br>\\ Bachelor of Engineering, Computer.\hfill { Overall CGPA: 9.05 }</pre><pre>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8qryT8lDbzDi3Bl2E-m70w.png" /><figcaption>Education section</figcaption></figure><p>The next section can be considered as a primary career goal professionally as well as personally. This section can be defined as “Career Objective” which is presented below:</p><pre>\begin{rSection}{Career Objective}<br> To work for an organization which provides me the opportunity to improve my skills and knowledge to grow along with the organization objective.<br>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFsXKXIh6WivwRSCSxA3DA.png" /><figcaption>Career’s long-term goal</figcaption></figure><p>From an academic perspective, projects play a crucial role in learning practical skills. Hence I consider placing “Projects” section in this position of the document. This is an aspect which can be tinkered as personal preferences go. For this section, general convention goes as the project’s name is provided in Bold styling, while the summary is presented from the next line in normal texts as described below. Here double slash(\\) represents new line. I have repeated the same project twice to demonstrate the exact spacing between projects.</p><pre>\begin{rSection}{Projects}</pre><pre>{\bf GitHub Notifier}<br>\\This project aims at providing real time information of events from GitHub and notify you accordingly. The project is in ready-to-deployment stage on a demo server as a cron-job. The notification engine  used for real time tracking is completely based on the python implementation assembled in an Android App with firebase cloud support.</pre><pre>{\bf GitHub Notifier}<br>\\This project aims at providing real time information of events from GitHub and notify you accordingly. The project is in ready-to-deployment stage on a demo server as a cron-job. The notification engine  used for real time tracking is completely based on the python implementation assembled in an Android App with firebase cloud support.</pre><pre>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*riDxA_b9EfaI0GYK50QpXA.png" /><figcaption>Project section. Note the spacing between each project</figcaption></figure><p>The next step in the resume is to demonstrate the skills and technical strengths you possess shortly and straightforwardly. Hence, a borderless table is mostly preferred for such visual aesthetics. A tabular section is used for creating table as shown below. An “&amp;” operator is used for diversification of each column, and a “\\” operator is used for new line attachment.</p><pre>\begin{rSection}{Technical Strengths}</pre><pre>\begin{tabular}{ @{} &gt;{\bfseries}l @{\hspace{6ex}} l }<br>Languages \ &amp; C, C++, Python, Java, C\#  \\<br>Technologies &amp; MVC, HTML5, CSS, Latex\\<br>Tools &amp; MikTex, Kile, Netbeans \\<br>Databases &amp; MySql, Oracle, Sqlite, NoSql\\<br>Cloud Technologies &amp; Firebase, AWS, Google Cloud\\<br>Version Control &amp; Github<br>\end{tabular}</pre><pre>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2YyP2s2GfEYzWKo9lQaQyQ.png" /><figcaption>Tabular Demonstration of Technical Strengths</figcaption></figure><p>The next section is considered as one of the most import aspects of your profile, which is the “Work Experience” section. This section needs to describe in brief the contribution you presented to the company in which you previously worked. In the case of an internship, the person should mention the same and accordingly summarize the role in the company. The class file provides a “rSubsection” template for such entries which can require multiple tags to represent the employee designation, company’s name, work duration, etc.. A section would contain a subsection for each entry of work profiling as shown below. Here each summary point is declared with a \item tag for equal spacing and design.</p><pre>\begin{rSection}{Work Experience}<br>\begin{rSubsection}{Reversible Alphabet Pvt. Ltd., India}{Jun 2017 - Dec 2018}{Data Scientist}{}<br> \item Created classification models for e-commerce websites using neural networks.<br> \item Achieved exposure towards classification optimaization techniques for further specialization.<br> \item Worked under an experenced Data Scientist and got deep insights related to optimization algorithms.<br>\end{rSubsection}<br>\begin{rSubsection}{Irreversible Alphabet Pvt. Ltd., India}{Jun 2016 - Dec 2016}{Data Scientist}{}<br> \item Created classification models for e-commerce websites using neural networks.<br> \item Achieved exposure towards classification optimaization techniques for further specialization.<br> \item Worked under an experenced Data Scientist and got deep insights related to optimization algorithms.<br>\end{rSubsection}</pre><pre>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Oj7Zy9ZkQ3YD6srL4J8Aw.png" /><figcaption>Note individual entry for each Job</figcaption></figure><p>Similarly, the sections as academic achievements, Extracurricular Activities, and Research Profile can be added in the following manner. Each section can be added just as given below as an example:</p><pre>\begin{rSection}{Academic Achievements} <br>\item Project &#39;XYZ&#39; won Best Project under Environmental Solver category under AICTE, Government of India<br>\item Recieved Scholarship For Higher Education(She) Component Under Inspire Scheme worth INR 4,00,000<br>\item Achived A Grade in Diploma in Computer Science from IBM<br>\item Won First Prize in Zonal technical quiz Competition Organized by IIT, Mumbai.<br>\item Project &#39;XYZ&#39; won Best Project under Environmental Solver category under AICTE, Government of India<br>\item Recieved Scholarship For Higher Education(She) Component Under Inspire Scheme worth INR 4,00,000<br>\item Achived A Grade in Diploma in Computer Science from IBM<br>\item Won First Prize in Zonal technical quiz Competition Organized by IIT, Mumbai.<br>\end{rSection}<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G6SPGy5ypvEQ60WmJrjIBQ.png" /><figcaption>Point-vise academic achievements</figcaption></figure><pre>\begin{rSection}{Extra-Cirrucular} <br>\item Attended a workshop on Machine Learning and artificial intelligence from faculties of IIT Roorkee in 2019 and won zonal round for the challenge presented.<br>\item Member of the  Institute of Engineers since 2017.<br>\item Completed Basic Leadership Training under Project NSS, Gujarat<br>\item Attended a workshop on Machine Learning and artificial intelligence from faculties of IIT Roorkee in 2019 and won zonal round for the challenge presented.<br>\item Member of the  Institute of Engineers since 2017.<br>\item Completed Basic Leadership Training under Project NSS, Gujarat<br>\item Attended a workshop on Machine Learning and artificial intelligence from faculties of IIT Roorkee in 2019 and won zonal round for the challenge presented.<br>\item Member of the  Institute of Engineers since 2017.<br>\item Completed Basic Leadership Training under Project NSS, Gujarat</pre><pre>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MD8pRnxqvnGhKExEUF7GtQ.png" /><figcaption>Extra Curricular Activities need to be emphasized</figcaption></figure><p>Similarly, the research section needs to be on the presented with the papers adequately documented and cited, for example(With Journal/conference name):</p><pre>\begin{rSection}{Research Profile}<br> \item Student President, Technology and Research, IIT Gandhinagar<br> \item Publication : ABC, IOT IEEE Transactions (Impact Factor: 9.3, Status: Published)<br> \item Student President, Technology and Research, IIT Gandhinagar<br> \item Publication : ABC, IOT IEEE Transactions (Impact Factor: 9.3, Status: Published)<br> \item Student President, Technology and Research, IIT Gandhinagar<br> \item Publication : ABC, IOT IEEE Transactions (Impact Factor: 9.3, Status: Published)<br>\end{rSection}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jyIE95wHPDRvjqcBezlW9w.png" /><figcaption>Research Work</figcaption></figure><p>Finally, after the addition of all the aspects of the profile, final proofreading of the document is required and a final draft needs to be prepared. It should be a general practice to let some colleague rectify the mistakes or ambiguities if any. <br>Resume building is an iterative task, which required constant tuning and twerking, which can only be achieved by adequate efforts. All the LaTeX code for the resume is provided in the GitHub link below.</p><blockquote>https://github.com/ridhamdave/resume-latex/blob/master/resume.tex</blockquote><p>The final PDF can be seen as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_e_9krXKJt1skBenf90QIA.png" /><figcaption>Final Resume</figcaption></figure><p>To conclude, you now have a great resume in your hand, which needs to be updated regularly in order to make it better. Just two words should always be kept in mind for resume building which are:</p><blockquote><strong>Precise </strong>and <strong>Concise</strong></blockquote><p>Hope you learned new techniques for efficient resume construction and are more familiar with the LaTeX environment for such professional tasks.</p><p>Thank you for your attention.</p><p>Also follow me on <a href="https://linkedin.com/in/ridham-dave-958015129/">LinkedIn </a>for networking.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7bc371f201e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/create-your-professional-educational-resume-using-latex-7bc371f201e3">Create your Professional/Educational resume using LaTeX</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Industrial Classification of Websites by Machine Learning with hands-on Python]]></title>
            <link>https://medium.com/data-science/industrial-classification-of-websites-by-machine-learning-with-hands-on-python-3761b1b530f1?source=rss-ad3f4f8773ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/3761b1b530f1</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[data-scraping]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[deep-neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ridham Dave]]></dc:creator>
            <pubDate>Mon, 30 Jul 2018 17:44:17 GMT</pubDate>
            <atom:updated>2020-12-04T19:57:12.342Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey folks, welcome to my first technical tutorial. In this tutorial, I would like to explain extraction, cleaning and classification of websites into different categories. I will use python environment to run my code for data scraping and use neural network to classify websites.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RWAmxUsenPRcXDtFVeRaYg.jpeg" /><figcaption>Text classification</figcaption></figure><p>Text classification is one of the widely used <strong>natural language processing</strong>(NLP) task in a lot of different areas of Data Science. An efficient text classifier can automatically distinguish the data into categories efficiently with the use NLP algorithms.</p><p><strong>Text Classification</strong> is an example of supervised machine learning task since a labelled dataset containing text documents and their labels is used for train a classifier.</p><p>Some common techniques for text classification are :</p><ol><li><a href="https://en.wikipedia.org/wiki/Naive_Bayes_classifier">Naive Bayes Classifier</a></li><li><a href="https://en.wikipedia.org/wiki/Linear_classifier">Linear Classifier</a></li><li><a href="https://en.wikipedia.org/wiki/Support_vector_machine">Support Vector Machine</a></li><li><a href="https://en.wikipedia.org/wiki/Bootstrap_aggregating">Bagging Models</a></li><li><a href="https://en.wikipedia.org/wiki/Gradient_boosting">Boosting Models</a></li><li><a href="https://en.wikipedia.org/wiki/Deep_learning">Deep Neural Networks</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEUIKPkdqR2O2lggQ4fA6g.jpeg" /></figure><p><a href="https://en.wikipedia.org/wiki/Web_scraping"><strong>Web scraping</strong></a>, <strong>web harvesting</strong>, or <strong>web data extraction</strong> is data scraping used for extracting data from websites. Generally, this is done with software that simulates human Web surfing to collect specified bits of information from different websites.</p><p>Some techniques that can be used for web scraping are :</p><ol><li>Human copy-and-paste</li><li>Text pattern matching</li><li>HTTP programming</li><li>HTML parsing</li><li>DOM parsing</li><li>Vertical aggregation</li><li>Semantic annotation recognizing</li><li>Computer vision web-page analysis</li></ol><p>In this tutorial, we will try to implement the complete model into three different modules :</p><ol><li>Data Scraping</li><li>Classification based on keywords for creating a training data set</li><li>Applying neural network for actual testing model</li></ol><h3>Module 1: Data Scraping</h3><p>In this module, I will use Python 3.5 environment to implement my scripts. So follow along for complete reference.</p><h4>Step 1: Requesting data from the website</h4><p>To extract web data many different packages are available, but in this tutorial I will use <a href="https://pypi.org/project/requests/"><em>requests</em></a><em>.</em></p><pre><strong>import</strong> <strong>requests<br>url=&#39;</strong>https://medium.com/<strong>&#39;<br>try:<br>    </strong>page = requests.get(url)        #to extract page from website<br>    html_code = page.content        #to extract html code from page<br>except <strong>Exception</strong> <strong>as</strong> e:<br>    print(e)</pre><p>In the above code, the requests.get() method will request the page from website using <em>https</em> protocol and load the page into the object “<em>page”. </em>The next line of code will move the HTML code to String <em>html_code. </em>So until now we have extracted the data from websites but it is still in HTML format which is far different than the actual text.</p><h4>Step 2: Extracting text from HTML page</h4><p>To extract complete text data from the HTML page, we have two highly preferred packages , <a href="https://www.crummy.com/software/BeautifulSoup/bs4/doc/"><strong>BeautifulSoup</strong></a> and <a href="https://pypi.org/project/html2text/"><strong>html2text</strong></a>. Using the <em>html_code </em>string found from the previous step, we can apply any of the following two methods.</p><pre><strong>from</strong> <strong>bs4</strong> <strong>import</strong> BeautifulSoup<br>try:<br>    soup = BeautifulSoup(html_code, &#39;html.parser&#39;)  #Parse html code<br>    texts = soup.findAll(text=<strong>True</strong>)                 #find all text<br>    text_from_html = &#39; &#39;.join(texts)                   #join all text<br>except <strong>Exception</strong> <strong>as</strong> e:<br>    print(e)</pre><p>In the above snippet, <strong>BeautifulSoup</strong> package will parse the HTML code and assign the data to <em>soup </em>object. The findall<em>()</em> function finds all visible text from code and return a list of Strings which we store in <em>texts. </em>And finally we join all individual text into a common string using <em>join() </em>function.</p><pre><strong>import</strong> <strong>html2text<br></strong>h = html2text.HTML2Text()                 #Initializing object<br>h.ignore_links = <strong>True                     </strong>#Giving attributes <strong><br>try:<br>    </strong>text = h.handle(html_code)            #handling the HTML code <br>    text_from_html=text.replace(&quot;<strong>\n</strong>&quot;,&quot; &quot;) #replacing next line char<br>except <strong>Exception</strong> <strong>as</strong> e:<br>    print(e)</pre><p>In this alternate block, we use package <strong>html2text </strong>to parse the string and directly get the text from the HTML code. Also we need to replace blank lines with spaces and finally find <em>text_from_html.</em></p><p>Similarly we can use a loop on some 1000+ urls and extract data from those sites as well and store them in a csv(Comma Separated File) format, which we can further use in the classification module.</p><h3><strong>Module 2 : Classification based on keywords</strong></h3><p>For any machine learning algorithm, we need some training set and test set for training the model and testing the accuracy of that model. Hence to create the set of data for the model, we already have the text from different websites, we will just classify them according to the keywords, and then apply the results in the next module.</p><p>In this tutorial, we are going to classify websites into three categories namely:</p><ol><li>Technology, Office, &amp; Education products website(Class_1)</li><li>Consumer products website(Class_2)</li><li>Industrial Tools and Hardware products website(Class_3)</li></ol><p>The approach here is that we will have certain keywords belonging to the particular category, and we will match those keywords with the text and find the class with the maximum <em>Matching_value.</em></p><blockquote><em>Matching_value </em>= (Number of keywords matched with one industry)/(Total number of keywords matched)</blockquote><p>So accordingly we have a list of keywords for the individual categories as follows:</p><pre>Class_1_keywords = [&#39;Office&#39;, &#39;School&#39;, &#39;phone&#39;, &#39;Technology&#39;, &#39;Electronics&#39;, &#39;Cell&#39;, &#39;Business&#39;, &#39;Education&#39;, &#39;Classroom&#39;]</pre><pre>Class_1_keywords = [&#39;Restaurant&#39;, &#39;Hospitality&#39;, &#39;Tub&#39;, &#39;Drain&#39;, &#39;Pool&#39;, &#39;Filtration&#39;, &#39;Floor&#39;, &#39;Restroom&#39;, &#39;Consumer&#39;, &#39;Care&#39;, &#39;Bags&#39;, &#39;Disposables&#39;]</pre><pre>Class_3_keywords = [&#39;Pull&#39;, &#39;Lifts&#39;, &#39;Pneumatic&#39;, &#39;Emergency&#39;, &#39;Finishing&#39;, &#39;Hydraulic&#39;, &#39;Lockout&#39;, &#39;Towers&#39;, &#39;Drywall&#39;, &#39;Tools&#39;, &#39;Packaging&#39;, &#39;Measure&#39;, &#39;Tag &#39;]</pre><pre>keywords=Class_1_keywords + Class_2_keywords + Class_3_keywords</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VFncY3rfxgnl_no4EOMcPQ.jpeg" /></figure><p>Now, we will use <a href="https://pypi.org/project/flashtext/"><strong>KeywordProcessor</strong></a> to find keywords inside the text recieved from the the urls.</p><p><a href="https://pypi.org/project/flashtext/"><strong>KeywordProcessor</strong></a><strong> </strong>is available in flashtext package on pypi.</p><pre><strong>from</strong> <strong>flashtext.keyword</strong> <strong>import</strong> KeywordProcessor<br>kp0=KeywordProcessor()<br><strong>for</strong> word <strong>in</strong> keywords:<br>    kp0.add_keyword(word)</pre><pre>kp1=KeywordProcessor()<br><strong>for</strong> word <strong>in</strong> Class_1_keywords:<br>    kp1.add_keyword(word)</pre><pre>kp2=KeywordProcessor()<br><strong>for</strong> word <strong>in</strong> Class_2_keywords:<br>    kp2.add_keyword(word)</pre><pre>kp3=KeywordProcessor()<br><strong>for</strong> word <strong>in</strong> Class_3_keywords:<br>    kp3.add_keyword(word)</pre><p>In the above code, we will load <strong>KeywordProcessor</strong> objects with the keywords which we will use further for finding the matching keywords.</p><p>To find percentage value of <em>Matching_value </em>we define a function percentage as follows:</p><pre><strong>def</strong> percentage1(dum0,dumx):<br>    <strong>try</strong>:<br>        ans=float(dumx)/float(dum0)<br>        ans=ans*100<br>    <strong>except</strong>:<br>        <strong>return</strong> 0<br>    <strong>else</strong>:<br>        <strong>return</strong> ans</pre><p>We will now use extract_keywords(string) method to find keywords present in the text. And we will find length of that list to find the number of matching keywords in the text. The following function will find the percentage and the class with maximum percentage is selected.</p><pre>def find_class:<br>    x=str(text_from_html)<br>    y0 = len(kp0.extract_keywords(x))<br>    y1 = len(kp1.extract_keywords(x))<br>    y2 = len(kp2.extract_keywords(x))<br>    y3 = len(kp3.extract_keywords(x))<br>    Total_matches=y0   <br>    per1 = float(percentage1(y0,y1))<br>    per2 = float(percentage1(y0,y2))<br>    per3 = float(percentage1(y0,y3))<br>    <strong>if</strong> y0==0:<br>        Category=&#39;None&#39;<br>    <strong>else</strong>:<br>        <strong>if</strong> per1&gt;=per2 <strong>and</strong> per1&gt;=per3:<br>            Category=&#39;Class_1&#39;<br>        <strong>elif</strong> per2&gt;=per3 <strong>and</strong> per2&gt;=per1:<br>            Category=&#39;Class_2&#39;<br>        <strong>elif</strong> per3&gt;=per1 <strong>and</strong> per3&gt;=per2:<br>            Category=&#39;Class_3&#39;<br>    return Category</pre><p>Using a loop on the above function, we can find the category of all websites based on the keywords. We will save the classified data into a file <em>Data.csv</em> which we will use further. So now we have our Data Set ready for applying neural network for classification.</p><h3>Module 3 : Applying neural network</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*P1Cxt9uu8RkD2YZWqbLrWw.png" /><figcaption>Classification of websites</figcaption></figure><p>In the following implementation, we will create a neural network from scratch and will use NLTK word tokenizer for preprocessing. First we need to import our dataset obtained from the above steps and load it into an list.</p><pre><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd<br></strong>data=pd.read_csv(&#39;Data.csv&#39;)<br>data = data[pd.notnull(data[&#39;tokenized_source&#39;])]<br>data=data[data.Category != &#39;None&#39;]</pre><p>The above code will load and clean the classified data. The NULL values will be removed.</p><p>The following code will create a dictionary of DATA against its class.</p><pre><strong>for</strong> index,row <strong>in</strong> data.iterrows():<br>    train_data.append({&quot;class&quot;:row[&quot;Category&quot;], &quot;sentence&quot;:row[&quot;text&quot;]})</pre><p>For applying neural network, we need to convert the Language Words into mathematical notations, which will be used for calculations. We will form a list of all the words across all the strings.</p><pre>words = []<br>classes = []<br>documents = []<br>ignore_words = [&#39;?&#39;]<br><em># loop through each sentence in our training data</em><br><strong>for</strong> pattern <strong>in</strong> training_data:<br>    <em># tokenize each word in the sentence</em><br>    w = nltk.word_tokenize(pattern[&#39;sentence&#39;])<br>    <em># add to our words list</em><br>    words.extend(w)<br>    <em># add to documents in our corpus</em><br>    documents.append((w, pattern[&#39;class&#39;]))<br>    <em># add to our classes list</em><br>    <strong>if</strong> pattern[&#39;class&#39;] <strong>not</strong> <strong>in</strong> classes:<br>        classes.append(pattern[&#39;class&#39;])<br><br><em># stem and lower each word and remove duplicates</em><br>words = [stemmer.stem(w.lower()) <strong>for</strong> w <strong>in</strong> words <strong>if</strong> w <strong>not</strong> <strong>in</strong> ignore_words]<br>words = list(set(words))<br><br><em># remove duplicates</em><br>classes = list(set(classes))<br><br>print (len(documents), &quot;documents&quot;)<br>print (len(classes), &quot;classes&quot;, classes)<br><em>print (len(words), &quot;unique stemmed words&quot;, words)</em></pre><p>For example, the output will be :</p><blockquote>1594 documents<br>3 classes [&#39;Class_1&#39;, &#39;Class_3&#39;, &#39;Class_2&#39;]<br><em>unique stemmed words 40000</em></blockquote><p>Now, we will create a <em>list of tokenized words for the pattern and also create a bag of words by using NLTK Lancaster Stemmer.</em></p><pre><strong>from</strong> <strong>nltk.stem.lancaster</strong> <strong>import</strong> LancasterStemmer</pre><pre>stemmer = LancasterStemmer()<br><em># create our training data</em><br>training = []<br>output = []<br><em># create an empty array for our output</em><br>output_empty = [0] * len(classes)<br><br><em># training set, bag of words for each sentence</em><br><strong>for</strong> doc <strong>in</strong> documents:<br>    <em># initialize our bag of words</em><br>    bag = []<br>    <em># list of tokenized words for the pattern</em><br>    pattern_words = doc[0]<br>    <em># stem each word</em><br>    pattern_words = [stemmer.stem(word.lower()) <strong>for</strong> word <strong>in</strong> pattern_words]<br>    <em># create our bag of words array</em><br>    <strong>for</strong> w <strong>in</strong> words:<br>        bag.append(1) <strong>if</strong> w <strong>in</strong> pattern_words <strong>else</strong> bag.append(0)<br><br>    training.append(bag)<br>    <em># output is a &#39;0&#39; for each tag and &#39;1&#39; for current tag</em><br>    output_row = list(output_empty)<br>    output_row[classes.index(doc[1])] = 1<br>    output.append(output_row)<br><br>print (&quot;# words&quot;, len(words))<br>print (&quot;# classes&quot;, len(classes))</pre><p>Output:</p><blockquote># words 41468<br># classes 3</blockquote><p>Now, we do the final preprocessing on the data and create some functions.</p><p><strong>Sigmoid Function</strong></p><pre><strong>def</strong> sigmoid(x):<br>    output = 1/(1+np.exp(-x))<br>    <strong>return</strong> output<br><br><em># convert output of sigmoid function to its derivative</em><br><strong>def</strong> sigmoid_output_to_derivative(output):<br>    <strong>return</strong> output*(1-output)</pre><p><strong>Cleaning function</strong></p><pre><strong>def</strong> clean_up_sentence(sentence):<br>    <em># tokenize the pattern</em><br>    sentence_words = nltk.word_tokenize(sentence)<br>    <em># stem each word</em><br>    sentence_words = [stemmer.stem(word.lower()) <strong>for</strong> word <strong>in</strong> sentence_words]<br>    <strong>return</strong> sentence_words</pre><p><strong>Bag Of Words function</strong></p><pre><strong>def</strong> bow(sentence, words, show_details=<strong>False</strong>):<br>    <em># tokenize the pattern</em><br>    sentence_words = clean_up_sentence(sentence)<br>    <em># bag of words</em><br>    bag = [0]*len(words)  <br>    <strong>for</strong> s <strong>in</strong> sentence_words:<br>        <strong>for</strong> i,w <strong>in</strong> enumerate(words):<br>            <strong>if</strong> w == s: <br>                bag[i] = 1<br>                <strong>if</strong> show_details:<br>                    print (&quot;found in bag: <strong>%s</strong>&quot; % w)<br><br>    <strong>return</strong>(np.array(bag))</pre><p>The final function which will be used in neural network : <strong>Think function</strong></p><pre><strong>def</strong> think(sentence, show_details=<strong>False</strong>):<br>    x = bow(sentence.lower(), words, show_details)<br>    <strong>if</strong> show_details:<br>        print (&quot;sentence:&quot;, sentence, &quot;<strong>\n</strong> bow:&quot;, x)<br>    <em># input layer is our bag of words</em><br>    l0 = x<br>    <em># matrix multiplication of input and hidden layer</em><br>    l1 = sigmoid(np.dot(l0, synapse_0))<br>    <em># output layer</em><br>    l2 = sigmoid(np.dot(l1, synapse_1))<br>    <strong>return</strong> l2</pre><p>Now we are all set to train our model of Neural Network. We are going to implement it through scratch and will be using Logistic regression into each neuron. With just one layer, but with 50000 epochs, we will be training our model. The complete training example will run on CPU.</p><pre><strong>def</strong> train(X, y, hidden_neurons=10, alpha=1, epochs=50000, dropout=<strong>False</strong>, dropout_percent=0.5):<br><br>    print (&quot;Training with <strong>%s</strong> neurons, alpha:<strong>%s</strong>, dropout:<strong>%s</strong> <strong>%s</strong>&quot; % (hidden_neurons, str(alpha), dropout, dropout_percent <strong>if</strong> dropout <strong>else</strong> &#39;&#39;) )<br>    print (&quot;Input matrix: <strong>%s</strong>x<strong>%s</strong>    Output matrix: <strong>%s</strong>x<strong>%s</strong>&quot; % (len(X),len(X[0]),1, len(classes)) )<br>    np.random.seed(1)<br><br>    last_mean_error = 1<br>    <em># randomly initialize our weights with mean 0</em><br>    synapse_0 = 2*np.random.random((len(X[0]), hidden_neurons)) - 1<br>    synapse_1 = 2*np.random.random((hidden_neurons, len(classes))) - 1<br><br>    prev_synapse_0_weight_update = np.zeros_like(synapse_0)<br>    prev_synapse_1_weight_update = np.zeros_like(synapse_1)<br><br>    synapse_0_direction_count = np.zeros_like(synapse_0)<br>    synapse_1_direction_count = np.zeros_like(synapse_1)<br>        <br>    <strong>for</strong> j <strong>in</strong> iter(range(epochs+1)):<br><br>        <em># Feed forward through layers 0, 1, and 2</em><br>        layer_0 = X<br>        layer_1 = sigmoid(np.dot(layer_0, synapse_0))<br>                <br>        <strong>if</strong>(dropout):<br>            layer_1 *= np.random.binomial([np.ones((len(X),hidden_neurons))],1-dropout_percent)[0] * (1.0/(1-dropout_percent))<br><br>        layer_2 = sigmoid(np.dot(layer_1, synapse_1))<br><br>        <em># how much did we miss the target value?</em><br>        layer_2_error = y - layer_2<br><br>        <strong>if</strong> (j% 10000) == 0 <strong>and</strong> j &gt; 5000:<br>            <em># if this 10k iteration&#39;s error is greater than the last iteration, break out</em><br>            <strong>if</strong> np.mean(np.abs(layer_2_error)) &lt; last_mean_error:<br>                print (&quot;delta after &quot;+str(j)+&quot; iterations:&quot; + str(np.mean(np.abs(layer_2_error))) )<br>                last_mean_error = np.mean(np.abs(layer_2_error))<br>            <strong>else</strong>:<br>                print (&quot;break:&quot;, np.mean(np.abs(layer_2_error)), &quot;&gt;&quot;, last_mean_error )<br>                <strong>break</strong><br>                <br>        <em># in what direction is the target value?</em><br>        <em># were we really sure? if so, don&#39;t change too much.</em><br>        layer_2_delta = layer_2_error * sigmoid_output_to_derivative(layer_2)<br><br>        <em># how much did each l1 value contribute to the l2 error (according to the weights)?</em><br>        layer_1_error = layer_2_delta.dot(synapse_1.T)<br><br>        <em># in what direction is the target l1?</em><br>        <em># were we really sure? if so, don&#39;t change too much.</em><br>        layer_1_delta = layer_1_error * sigmoid_output_to_derivative(layer_1)<br>        <br>        synapse_1_weight_update = (layer_1.T.dot(layer_2_delta))<br>        synapse_0_weight_update = (layer_0.T.dot(layer_1_delta))<br>        <br>        <strong>if</strong>(j &gt; 0):<br>            synapse_0_direction_count += np.abs(((synapse_0_weight_update &gt; 0)+0) - ((prev_synapse_0_weight_update &gt; 0) + 0))<br>            synapse_1_direction_count += np.abs(((synapse_1_weight_update &gt; 0)+0) - ((prev_synapse_1_weight_update &gt; 0) + 0))        <br>        <br>        synapse_1 += alpha * synapse_1_weight_update<br>        synapse_0 += alpha * synapse_0_weight_update<br>        <br>        prev_synapse_0_weight_update = synapse_0_weight_update<br>        prev_synapse_1_weight_update = synapse_1_weight_update<br><br>    now = datetime.datetime.now()<br><br>    <em># persist synapses</em><br>    synapse = {&#39;synapse0&#39;: synapse_0.tolist(), &#39;synapse1&#39;: synapse_1.tolist(),<br>               &#39;datetime&#39;: now.strftime(&quot;%Y-%m-<strong>%d</strong> %H:%M&quot;),<br>               &#39;words&#39;: words,<br>               &#39;classes&#39;: classes<br>              }<br>    synapse_file = &quot;synapses.json&quot;<br><br>    <strong>with</strong> open(folder_path+synapse_file, &#39;w&#39;) <strong>as</strong> outfile:<br>        json.dump(synapse, outfile, indent=4, sort_keys=<strong>True</strong>)<br>    print (&quot;saved synapses to:&quot;, synapse_file)</pre><p>And finally we will train the model :</p><pre>import time<br>X = np.array(training)<br>y = np.array(output)<br><br>start_time = time.time()<br><br>train(X, y, hidden_neurons=10, alpha=0.1, epochs=50000, dropout=<strong>False</strong>, dropout_percent=0.2)<br><br>elapsed_time = time.time() - start_time<br>print (&quot;processing time:&quot;, elapsed_time, &quot;seconds&quot;)</pre><p>Output :</p><blockquote>Training with 10 neurons, alpha:0.1, dropout:False <br>Input matrix: 1594x41468 Output matrix: 1x3<br>delta after 10000 iterations:0.0665105275385<br>delta after 20000 iterations:0.0610711168863<br>delta after 30000 iterations:0.0561908365355<br>delta after 40000 iterations:0.0533465919346<br>delta after 50000 iterations:0.0461560407785<br>saved synapses to: synapses.json<br>processing time: 33060.51151227951 seconds</blockquote><p>As we can see, it took almost 11 hours hours to train the model. And after such an intensive calculations, we are ready to test the data.</p><p>The function to test the data :</p><pre><em># probability threshold</em><br>ERROR_THRESHOLD = 0.2<br><em># load our calculated synapse values</em><br>synapse_file = &#39;synapses.json&#39; <br><strong>with</strong> open(synapse_file) <strong>as</strong> data_file: <br>    synapse = json.load(data_file) <br>    synapse_0 = np.asarray(synapse[&#39;synapse0&#39;]) <br>    synapse_1 = np.asarray(synapse[&#39;synapse1&#39;])<br><br><strong>def</strong> classify(sentence, show_details=<strong>False</strong>):<br>    results = think(sentence, show_details)<br><br>    results = [[i,r] <strong>for</strong> i,r <strong>in</strong> enumerate(results) <strong>if</strong> r&gt;ERROR_THRESHOLD ] <br>    results.sort(key=<strong>lambda</strong> x: x[1], reverse=<strong>True</strong>) <br>    return_results =[[classes[r[0]],r[1]] <strong>for</strong> r <strong>in</strong> results]<br>    <em>#print (&quot;\n classification: %s&quot; % ( return_results))</em><br>    <strong>return</strong> return_results</pre><p>Lets test the model with its accuracy :</p><pre>classify(&quot;Switchboards Help KA36200 About Us JavaScript seems to be disabled in your browser You must have JavaScript enabled in your browser to utilize the functionality of this website Help Shopping Cart 0 00 You have no items in your shopping cart My Account My Wishlist My Cart My Quote Log In BD Electrical Worldwide Supply Remanufacturing the past SUSTAINING THE FUTURE Hours and Location Michigan Howell&quot;)</pre><p>Output:</p><blockquote>[[&#39;Class_3&#39;, 0.97663437888614435]]</blockquote><pre>classify(&quot;  New Website Testimonial Policies Parts Catalog Contact Support Forum Documentation Themes WordPress Blog Products Spindle Parts Latest News Kennard Parts Suggest Ideas Legal/Disclaimers WordPress Planet News About CDT Home Latest News Testimonial Products Parts Catalog About CDT History Staff Policies Centrum Legal Disclaimers Contact About CDT Custom Drilling Technologies established in 1990 has been providing superior customer service to the printed circuit board industry for almost 20 years We specialize in Excellon Drilling and Routing Equipment Parts and Service Our staff has over sixty years of combined experience in the design building troubleshooting operation programming&quot;)</pre><p>Output:</p><blockquote>[[&#39;Class_1&#39;, 0.9620297535870017]]</blockquote><p>As you can see, we are getting pretty high accuracy on these tests. I have tried this model on different data, and have found pretty higher accuracy.</p><p>An accuracy of around 95%+ is considered pretty accurate in this type of model with just one layer. For further classification by different models, we can use Keras or Tensorflow. To decrease the time to train the model, we can use a NVIDIA GPU.</p><p>And now we can easily scrape data and classify its category, with the help of Deep Neural Network using Back Propogation .</p><p>In the further tutorials, I will try to explain Keras and Tensorflow’s working and hands-on.</p><p>Please share your feedback about this tutorial in comment section below or via my LinkedIn page: <a href="https://www.linkedin.com/in/ridhamdave/">https://www.linkedin.com/in/ridhamdave/</a> . Also share your doubts regarding this tutorial.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3761b1b530f1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/industrial-classification-of-websites-by-machine-learning-with-hands-on-python-3761b1b530f1">Industrial Classification of Websites by Machine Learning with hands-on Python</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>