<?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 Shaziya on Medium]]></title>
        <description><![CDATA[Stories by Shaziya on Medium]]></description>
        <link>https://medium.com/@machine.learning?source=rss-ba7500651422------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*otIMB5Z5oeREYIqeh8gp8A.jpeg</url>
            <title>Stories by Shaziya on Medium</title>
            <link>https://medium.com/@machine.learning?source=rss-ba7500651422------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 16:18:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@machine.learning/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[Machine Learning Introduction]]></title>
            <link>https://medium.com/analytics-vidhya/machine-learning-introduction-2f442bc34855?source=rss-ba7500651422------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f442bc34855</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Shaziya]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 18:36:27 GMT</pubDate>
            <atom:updated>2020-04-30T17:18:08.221Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*FzCn3DrhKcwoxMEf005mrQ.jpeg" /></figure><blockquote><strong>What is Machine Learning?</strong></blockquote><p>Machine Learning is turning the data into information.</p><p>Machine Learning is programming computer to optimized a performance criteria using example data or past experience.</p><p>Example<br><strong>1) Super market Chain:</strong><br>The system warns an algorithm to predict which customer is likely to buy which products and to maximize the sales and profit. Similarly each customer wants to find the set of products best matching his/her needs.<br>eg. If bread then butter and vice versa.</p><p><strong>2)Email(Spam):</strong><br>In detecting the spam mail, we need to look certain keywords combine with each other. The factors like length of email, frequency of email to decide whether the email is spam or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*zSqDp85_HlMSa9V7Rh63lQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*bODBr9b_vmq003dlA01-CA.png" /></figure><h3><strong>Key Terminologies:</strong></h3><ol><li><strong>Features:</strong><br>They are also called as attributes. In the given dataset, we have used four attributes. They are weight, wingspan, webbed feet, back color. Weight and wingspan are numeric and webbed feet is boolean and back color is alphanumeric.</li><li><strong>Target Variable:</strong><br>It is output of the given dataset. In the given training eg. we have species as target variable.</li><li><strong>Training Set:</strong><br>It is a set of training, we used to train our machine learning algorithm. In the given eg. we have six training set.</li><li><strong>Classification:</strong><br>It is a technique in which we have to combine all the features and to decide the species with the help of an algorithm.</li><li><strong>Test Set:</strong><br>It is used for comparing the predicted value with the available value to sense the accuracy of an algorithm.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*TaWFsgTqN0NpZTDUiAZatw.png" /></figure><blockquote><strong>Types of Machine Learning:</strong></blockquote><ol><li><strong>Supervised Learning:</strong><br>In supervised learning, the training data you feed to the algorithm includes the desired solutions, called as labels.<br>A typical supervised learning task is classification. The spam filter is a good example of this: it is trained with many example email along with their class(spam or ham), and it must learn how to classify new emails.<br>Another typical task is to predict a target numeric value, such as the price of a car given set of features(mileage, age, brand etc.) called predictors. This sort of task is called regression. To train the system, you need to give it many example of cars, including both their predictors and their labels. Note that some regression algorithms can be used for classification as well, and vice versa. For example, Logistic Regression is commonly used for classification, as it can output a value that corresponds to the probability of belonging to a given class.<br>Here are some of the most important supervised learning algorithms:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*r4-coDJkf1vdb2OV8DGHmQ.png" /></figure><p><strong>2)Unsupervised Learning:</strong><br>In this learning type, we don’t have any supervisor only we have raw data. The aim is to find the regularities of the input pattern. There will be a pattern which will occur more than often. This method used is called clustering, where the aim is to find the clusters or grouping of input.<br>eg. In document clustering, the aim is to group similar document news, reports can be subdivided as those related to politics, sports, fashion etc. Other examples are customer segmentation, image compression etc. <br>Here are some important unsupervised learning algorithms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*bVKk2tK7l1L6arK8bLEw6g.png" /></figure><p>For example you have lots of data about your blog’s visitor. You may want to run a clustering algorithm to try to detect groups of similar visitors. At no point do you tell the algorithm which groups the visitors belong to: it finds those connections without your help. For example, it might notice that 40% of your visitors are males who love comic books are generally read your blog in the earning, while 20% are young sci-fi lovers who visit during the weekends, and so on. If you use a hierarchical clustering algorithm, it may also subdivided each group into smaller groups. This may help you target your posts for each group.</p><p><strong>3) Reinforcement Learning:</strong><br>The output of the system is sequence of the action in such a case a single action is not important what is important is the policy of correct action to reach the goal. An action is good if it is a part of good policy.<br>It is very different beast. The learning system, called an agent in this context, can be observed by the environment, select and perform action, and get rewards in return. A policy defines what action the agent should choose when it is in a given situation.</p><p>eg. In an game playing system, Chess where a single move is not important. Sequence of right moves are important.</p><blockquote><strong>Advantages of Machine Learning:</strong></blockquote><ol><li>It helps the system to take decision on the basis of training data.</li><li>It can handle multidimensional data.</li><li>It extract implicit relationship within the large data.</li><li>It allows the reduction of time cycle.</li><li>It improves the resource utilization.</li><li>It provides the tool for quality improvement.</li><li>It improves the classification performance.</li></ol><blockquote><strong>Application of Machine Learning:</strong></blockquote><ol><li>Banking and financial Services:<br>Machine Learning is widely used to predict the customers who are likely to be default in paying the credit card bills or repaying the loans. It also helps the bank to identify the customer who can be given credit card and loans.</li><li>Healthcare:<br>It is used to diagnose various deadly disease like cancer on the basis of patient symptoms and telly them with the past data available for similar kind of patient.</li><li>Retails:<br>It is used to identify the products that sells fats and those don’t. It helps the retail of to decide the strategies. Walmart, amazon, bigbazaar or such retail units are extensively used machine learning.</li><li>Publishing and Social Media:<br>There are different publishing firms like McGraw Hills which make used machine learning to run the queries and fetch the documents required by the user online. Google and facebook also used machine learning to rank their search output news feeds. Friend suggestion in facebook used machine learning.</li><li>Robot Locomotion:<br>It is basically a collective terms used for different methods that robot used to transport themselves from one place to other. A measure challenge in this field is developing a capabilities for robot to decide about how where and when to move.</li></ol><p>I hope you guys understand the basic idea about the machine learning.<br>If you enjoy my work and want to keep up to date with the latest publications or would like to get in touch, I can be found on medium <a href="https://medium.com/@machine.learning">Shaziya Memon</a> and twitter <a href="https://twitter.com/Smemon79402105"><strong>@Smemon</strong></a><strong> -Thanks</strong></p><p>Happy Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f442bc34855" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/machine-learning-introduction-2f442bc34855">Machine Learning Introduction</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[Naive Bayes Classification]]></title>
            <link>https://medium.com/analytics-vidhya/naive-bayes-classification-aa381b00dd45?source=rss-ba7500651422------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa381b00dd45</guid>
            <category><![CDATA[naive-bayes-in-python]]></category>
            <category><![CDATA[naive-bayes-classifier]]></category>
            <category><![CDATA[scikit-learn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <dc:creator><![CDATA[Shaziya]]></dc:creator>
            <pubDate>Fri, 24 Apr 2020 22:03:45 GMT</pubDate>
            <atom:updated>2020-04-27T18:27:55.371Z</atom:updated>
            <content:encoded><![CDATA[<h3>Naive Bayes Classifier</h3><p>Naive Bayes is a supervised learning classification. It is a probabilistic classifier based on Bayes theorem. The name naive stems from the fact that classifier assumes that pairs of features are independent, thus significantly simplifying the model parameters are training requirements. This simplifies the computation that’s why it is called as ‘naive’. This is also called as class independence.</p><p><strong>Conditional probability:</strong><br>Consider seven balls in the bucket out of which three are blue and four are black, then the probability of removing the blue ball from the bucket is 3/7 and similarly the probability of removing the black ball is 4/7.</p><p>Let us apply the condition, there are two bucket. Bucket A and bucket B.<br>In bucket A there are two black balls and two blue balls similarly in bucket B there are two black balls and one blue ball.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*toZj7oH_x5Weix5-5TbaSQ.png" /></figure><p>Probability of getting blue ball in bucket B is<br> P(blue / bucket B)=1/3<br>OR<br> P(blue / bucket B)=P(blue and bucket B)/P(bucket B)<br>P(blue / bucket B)=(1/7)/(3/7)<br>P(blue / bucket B)=1/3</p><p>The above formula is based on probability of c on x</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*E9KFmjrKdGH0h0PFNnmU2g.png" /></figure><p>Training data D posterior of probability of hypothesis h follows the base theorem as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*agOPFlEtIVuWK-J0HwalYA.png" /></figure><p>where,<br>P(h) : Independent probability of hypothesis also called as prior probability<br>P(D) : Independent probability of given dataset<br>P(D|h) : Conditional probability of D given h also called as likelihood probability<br>P(h|D) : Conditional probability of h given D also called as posterior probability</p><blockquote><strong>Naive Bayes Algorithm in Python with scikit learn</strong></blockquote><p>In this example, we used placement dataset to find out how many number of students are placed and how many number of students are not.</p><p>I generally used google colab to write a code. It is amazing platform. For that <br>first you have to mount the google drive into google colab. So that we can access the dataset from google dive. We use following code</p><pre>from google.colab import drive<br>drive.mount(&#39;/content/drive&#39;)</pre><p>Importing the required libraries</p><pre>import pandas as pd<br>import numpy as np<br>import seaborn as sns<br>import matplotlib.pyplot as plt<br>from sklearn.model_selection import train_test_split<br>from sklearn.metrics import classification_report, confusion_matrix, accuracy_score</pre><p>After that I have to read csv file (dateset) <a href="https://drive.google.com/file/d/1IlowRit-W0R2sDsEYvyeZNO_7y3kG3gc/view?usp=sharing">click here</a> to download the dataset.</p><pre>df = pd.read_csv(&#39;/content/drive/My Drive/placement.csv&#39;)<br>df</pre><p><strong>Preprocessing of data:</strong><br>First we have to check that dataset contain any null value or not if it contain we have to apply the some transformation into it.</p><pre>df.isnull().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*ijecRK_fpQVJTmHk77kOPg.png" /></figure><p>shape method returns a tuple representing the dimensionality of the DataFrame.</p><pre>df.shape</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/203/1*xsMKDjNLwAI_liqKys32aQ.png" /></figure><p>info() is used to print the concise summary of dataframe</p><pre>df.info()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*yK0xJdH6y5ssH1ZGPdqfAw.png" /></figure><p><strong>Data Visualization:</strong><br>It aims to communicate data clearly &amp; efficiently through graphical representation.</p><pre>sns.countplot(x=’status’,data=df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*UIklRedZyheL1sZbEd1tHQ.png" /></figure><pre>sns.countplot(x=’status’,hue=’gender’,data = df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*dXibVenNtLp9JZIhvGmJVg.png" /></figure><p>Convert categorical variable into indicator variables</p><pre>workexp= pd.get_dummies(df[‘workex’])<br>workexp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*MFldBu44H7dTir3aFeIdGw.png" /></figure><p>Concatenate the data into original dataset.</p><pre>df=pd.concat([df,workexp],axis=1)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7z5sgiZcqgXT32Scd9ETw.png" /></figure><pre>df.drop([‘sl_no’,’gender’,’ssc_b’,’hsc_b’,’hsc_s’,’degree_t’,’workex’,’specialisation’],axis=1,inplace=True)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Rk9tpDPhSL8vP9S_uaxaFw.png" /></figure><p>Training and testing data</p><pre>X=df.drop(‘status’,axis=1)<br>y=df[‘status’]<br>X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=1)</pre><p>Apply the Naive Bayes theorem</p><pre>from sklearn.naive_bayes import GaussianNB<br>model = GaussianNB()<br>model.fit(X_train,y_train)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*tzsK41mh9tvYeXIkG011Lw.png" /></figure><p>Compare the actual status and predicted status</p><pre>y_pred=model.predict(X_test)<br>df1=pd.DataFrame({‘Actual Status’:y_test,’Predicted Status’:y_pred})<br>df1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*iudSPmGsWN3yOEVwzquEMg.png" /></figure><p>Classification Report:<br>A Classification report is used to measure the quality of predictions from a classification algorithm.</p><pre>print(classification_report(y_test, y_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*_S3SbsoOlHiWAGMM6cXySg.png" /></figure><p>Confusion Matrix:<br>A confusion matrix is a summary of prediction results on a classification problem. The number of correct and incorrect predictions are summarized with count values and broken down by each class.</p><pre>print(confusion_matrix(y_test,y_pred))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/138/1*XLRZXS-fP5VDmQF92U9gQw.png" /></figure><p>Accuracy Score:</p><pre>print(accuracy_score(y_test,y_pred)*100)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/342/1*vBpaSdQikQ7_W0GVFWiUjw.png" /></figure><p>In this article, we studied machine learning algorithm i.e. Naive Bayes Classification.<br>Also, we implemented Naive Bayes Classification using scikit learn.</p><p>I hope you guys understand how to implement Naive Bayes Classification. Let me know your doubts and suggestions in comment section.</p><p>Happy Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa381b00dd45" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/naive-bayes-classification-aa381b00dd45">Naive Bayes Classification</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[Hemp: the only plant that can feed you, house you & heals you..]]></title>
            <link>https://medium.datadriveninvestor.com/hemp-the-only-plant-that-can-feed-you-house-you-heals-you-75582f86f12d?source=rss-ba7500651422------2</link>
            <guid isPermaLink="false">https://medium.com/p/75582f86f12d</guid>
            <category><![CDATA[hemp]]></category>
            <category><![CDATA[hemp-product]]></category>
            <category><![CDATA[cannabis]]></category>
            <dc:creator><![CDATA[Shaziya]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 16:38:44 GMT</pubDate>
            <atom:updated>2020-04-28T16:09:15.039Z</atom:updated>
            <content:encoded><![CDATA[<p>Hemp is part of cannabis family. The botanical name of hemp is Cannabis Sativa L. The benefits of hemp start from head to toe. Hemp may reduce your risk of heart disease, hemp seeds and oil may benefit skin disorders. Hemp seeds are a great source of plant-based protein so now you have the answer to your non-processed protein needs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*UIhwjvsRTEETo6ZHEEiGuQ.jpeg" /></figure><p>Hemp has not only been used for human well-being but for industrial purpose as well, did you know in 1941 Henry Ford introduced a car made up of all hemp, 10x stronger than steel and 40% lighter than steel. Not just the car but also the constitution of the united states was written on hemp paper.</p><p>It has been an important source of food and fiber with references dating back to ancient China and Mesopotamia. Applications of hemp plants evolved from simple rope and coarse woven fabric to paper and sailcloth. Hemp enriches the soil where it’s grown. Hemp has such deep roots that it can easily grow in many different types of soil and terrains. It even holds the soil together and increases its microbial content. Once the plant is harvested, the stem and leaves are so nutrient-filled that many farmers put what they don’t use back in the soil, which rejuvenates it and results in an even bigger yield the next year. Hemp absorbs toxic metals. Hemp has shown it can eliminate toxins and radioactive material from the environment.</p><p>Scientists planted it at Chernobyl and found that hemp conducted phytoremediation and removed chemicals from the soil better than any other plant.</p><p>Hemp can reduce carbon emissions. According to Vedas hemp is one of the five sacred plants, it is also the oldest known plant to man and has been cultivated for centuries for several purposes like rope, paper, textile, Medicinal uses. Hemp is the new building material. The high amount of fibre available in hemp makes it a good choice for making building blocks. Hemp is also used as an insulating material for house construction in cold countries.</p><p><a href="https://www.datadriveninvestor.com/2018/11/14/forget-about-oil-water-is-the-future/">Forget about Oil, Water is the future. | Data Driven Investor</a></p><p>Hemp can not only replace some of the causes of carbon emissions, hemp can eliminate carbon emissions. Hemp has such a high carbon-dioxide uptake that it creates a process called carbon sequestration, which captures emissions.</p><p>Did you know you can even make fabrics and finished clothes from hemp. It takes a about 2700 litres of water to make just one cotton shirt i.e one hectare of cotton cultivation needs approximately 255515.3 litres of water, whereas a hectare of hemp farming done on just 114 litres of water can make more than 34 shirts hence hemp is known as the sustainable plant.</p><p>Hemp has been used in japan and portugal for several centuries. Hemp is known as &quot;asa&quot; in japanese. Hemp contains about 3% gamma-linoleic acid (gla).the unique ratio of omega-6 to omega-3 ensures that you can consume hemp without needing to balance it with any other food rich in fat.</p><p>I hope you like this article. If you have any suggestions, please let me know in the comment section.<br>Happy Learning!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75582f86f12d" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/hemp-the-only-plant-that-can-feed-you-house-you-heals-you-75582f86f12d">Hemp: the only plant that can feed you, house you &amp; heals you..</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logistic Regression]]></title>
            <link>https://medium.com/analytics-vidhya/logistic-regression-a8e3d7c2e5ee?source=rss-ba7500651422------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8e3d7c2e5ee</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[scikit-learn]]></category>
            <dc:creator><![CDATA[Shaziya]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 07:41:21 GMT</pubDate>
            <atom:updated>2020-04-28T16:51:46.411Z</atom:updated>
            <content:encoded><![CDATA[<p>Logistic Regression is supervised learning classification algorithm. In this algorithm the target attribute or dependent variable is dichotomous, which means there would be only two possible classes. In simple words, the dependent variable is binary in nature having data coded as either 1 (stands for yes/positive/success) or 0 (stands for no/negative/fail). It is used to estimate the probability that an instance which is belong to particular class.</p><p>We use the logistic function given as,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/158/1*zz3s8DovQcY7u9_-0dGYEQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*EvpNwNHLUIWksyugWNHt2g.png" /></figure><p>The logistic function has following characteristics:<br>It has value between 0 and 1.<br>It converges to 1 and approaches to +∞.<br>It converges to 0 and approaches to -∞.<br>It is smooth and symmetric curve.</p><p><strong>Logistic Regression in Python with scikit learn:</strong></p><p>In the given example we have determine that how many peoples are survived in the titanic and how many peoples are not. For that we have to import the required libraries.</p><pre>import pandas as pd<br>import numpy as np<br>import seaborn as sns<br>import matplotlib.pyplot as plt<br>from sklearn.model_selection import train_test_split<br>from sklearn.linear_model import LogisticRegression<br>from sklearn.metrics import classification_report,confusion_matrix,accuracy_score</pre><p>The following command is used to read the CSV file using pandas.<br>Download the dataset: <a href="https://www.kaggle.com/hesh97/titanicdataset-traincsv">click here</a></p><pre>df=pd.read_csv(&#39;/content/drive/My Drive/titanic.csv&#39;)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KqnJkBf0Hb4P_h-gNCWzdA.png" /><figcaption>titanic.csv</figcaption></figure><p>Visualize the Data:</p><pre>df.hist()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_aHp5OZbavWNwnI0CbKlrg.png" /></figure><pre>sns.countplot(x = &#39;Survived&#39;,data = df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*wxzq23itDkC1Bi4RdqSPrQ.png" /></figure><pre>sns.countplot(x = ’Survived’,hue = ’Sex’,data = df)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*mebNJq_UPQaMJD8hdTIbTA.png" /></figure><p>Data preprocessing:</p><pre>df.isnull().sum()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*Zw4w_2r9Sxkr8pgzBLiW1w.png" /></figure><pre>sns.heatmap(df.isnull(),yticklabels = False)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*AiTuwr8H0sQbmsLJw7zAhA.png" /></figure><p>Convert categorical variable into indicator variables</p><pre>sex = pd.get_dummies(df[‘Sex’])<br>sex</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*6MIStsy7cdY_StjgHmWo4Q.png" /></figure><pre>embarked = pd.get_dummies(df[‘Embarked’])<br>embarked</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*O3TRR_5bpdjbWvHirXPLCw.png" /></figure><p>Remove the unnecessary columns from dataset</p><pre>df.drop([‘Sex’,’Embarked’,’PassengerId’,’Name’,’Ticket’,’Fare’,’Cabin’,’Parch’,’SibSp’,’Age’],axis=1,inplace=True)</pre><p>Concatenate the required columns</p><pre>df=pd.concat([df,sex,e],axis=1)<br>df</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/441/1*xsTCemUzs8aLnPkQLEFoQQ.png" /></figure><p>The dataset is divided into “attributes” and “labels”. Attributes are the independent variables while labels are dependent variables whose values are to be predicted. In this example, Pclass, sex, embarked are the independent variables while Survived is dependent variable.</p><pre>X = df.drop(“Survived”,axis=1)<br>y = df[“Survived”]</pre><p>Train and Testing the data:</p><pre>X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=1)</pre><p>After splitting the data into training and testing sets, it is a time to train our algorithm. For that we used Logistic Regression</p><pre>model = LogisticRegression()<br>model.fit(X_train,y_train)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*vJ9lbxxsCnj33YXqb9lh7g.png" /></figure><pre>y_pred = model.predict(X_test)<br>y_pred</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*ASbktgBqL6_szCSCkdzo_A.png" /></figure><p>Display the confusion matrix:<br>A confusion matrix is a summary of prediction results on a classification problem. The number of correct and incorrect predictions are summarized with count values and broken down by each class.</p><pre>confusion_matrix(y_test,y_pred)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*7TIhPurTYAQoTKiLerqIXA.png" /></figure><p>Find out the accuracy score</p><pre>print(‘Accuracy Score:’,accuracy_score(y_test,y_pred)*100)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*HPgWB6cYk0Qg_t4ytn0Ivg.png" /></figure><p><strong>Conclusion:</strong><br>In this article, we studied machine learning algorithm i.e. Logistic Regression.<br>We implemented Logistic Regression using scikit learn.</p><p>I hope you guys understand how to implement Logistic Regression. Let me know your doubts and suggestions in comment section.</p><p>Happy Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8e3d7c2e5ee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/logistic-regression-a8e3d7c2e5ee">Logistic Regression</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>