1. Home
  2. Explore
  3. Computer Science
  4. Machine Learning Basics

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Machine Learning Basics

Transcript

Hello everyone and welcome to this interesting session on machine learning. So before we move forward with our session, let's have a quick look at the agenda. So first of all I'll be starting with an introduction to data science wherein I'll discuss how the growth of data are led to the introduction of data science and how machine learning became a very important part of data science so then again we'll discuss what exactly is machine learning and the various application of machine learning in the day-to-day life and in the industry as well and moving forward we'll discuss the various types of machine learning which are namely the supervised unsupervised and the reinforcement learning and we'll discuss all of these three types of machine learning in depth wherein he'll discuss the various algorithms which are present in these supervised and supervised and unsupervised learning and we'll discuss

how what is the math behind all of these algorithm how these algorithms works I will also have quite a few demos in this session so stay tuned to learn more about machine learning so let's get started now data as we know is increasing at a very alarming rate and we are generating 2.5 quintillion bytes of it every day we are living in an era of technological transformation that is bringing about changes in the way we take decisions aspect data is becoming pervasive across all the industries use of machines to find patterns and predict futures is gaining a lot of prominence in the market now what better way to discuss the growth operator generation and subsequent workplace demand than with some sound statistics so let me start with a few lines or the data points that were published in a McKinsey report so the report stated that the United States alone faces a shortage of 140,000 to 190,000 people with article

expertise and 1.5 million managers and analysts with the skills to understand and make decisions based on the analysis of picked aid now pay attention to the words with the skills to understand and make decisions based on the analysis of big data the industry will require a lot of big data and machine learning experts and needs even more about 10% people who can make decisions based on the analysis even though they might not exports on machine learning so what exactly is data science so read a science is also known as data-driven science and it is an interdisciplinary field about scientific methods processes and systems to extract knowledge or insights from the data in various forms either structured or unstructured it is the study where information comes from what it represents and how it can be turned into a valuable resource in the creation of business and IT strategies related science employs many techniques

and theories from fees like mathematics statistics information science and computer science it can be applied to small data sets also yet most people think the error science is when you are dealing with big data or large or soft data now if you have a look at the peripherals of the data science we have statistics we had different programming languages we have our Python we have SS then again we have software which we deal with in which we bundle up our whole model and present the findings to the customer or wherever it is required then again we have machine learning which is the main topic of our session today and then again finally we have Big Data so let's focus on machine learning today and understand what exactly is machine learning so machine learning is an application of artificial intelligence that provides systems the ability to automatically learn and improve from experience without being

explicitly programmed now getting computers to program themselves and also teaching them to make decisions using data where writing software is a bottleneck let the data do the work instead now much--he learning is a class of algorithms which is data driven that is unlike normal algorithms it is the data that does what the good answer is so if we have a look at the various features of machine learning so first of all it uses the data to detect patterns in a data set and adjust a program actions accordingly it focuses on the development of computer programs that can teach themselves to grow and change when exposed to new data so it's not just the old data on which it has been trained so whenever a new data is entered the program changes accordingly it enables computers to find hidden insights using it algorithms without being explicitly programmed either so machine learning is a method of data analysis that automates

analytical model building now let's understand how exactly it was so if we have a look at the diagram which is given here we have traditional programming on one side we have machine learning on the other so first of all in traditional program what we used to do was provide the data provide the program and the computer used to generate the output so things have changed now so in machine learning what we do is provide the data and we provide a predicted output to the machine now what the machine does is learns from the data find hidden insights and creates a model now it takes the output data also again and it reiterates and trains and grows accordingly so that the model gets better every time it's strained with the new data or the new output so the first and the foremost application of machine learning in the industry I would like to get your attention towards is the navigation or the Google Maps so Google

Maps is probably the app we use whenever we go out and require assistant in directions and traffic right the other day I was traveling to another city and took the expressway and the map suggested despite the havoc traffic you are on the fastest route no but how does it know that well it's a combination of people currently using the services the historic data of that fruit collected over time and a few tricks acquired from the other companies everyone using maps is providing their location their average speed the route in which they are traveling which in turn helps Google collect massive data about the traffic which may accelerate the upcoming traffic and it adjust your route according to it which is pretty amazing right now coming to the second application which is the social media if we talk about Facebook so one of the most common application is automatic friend tanks suggestion in Facebook and

I'm sure you might have gotten this so it's present in all the other social media platform as well so Facebook uses face detection and image recognition to automatically find the face of the person which matches its database and hence it suggests us to tag that person based on deep face deface is Facebook's machine learning project which is responsible for recognition of faces and define which person is in picture and it also provides alternative tags to the images already uploaded on Facebook so for example if we have a look at this image and we introspect the following image on Facebook we get the alt tag which has a particular description so in our case what we get here is the image may contain sky grass outdoor and nature now transportation and commuting is another industry where machine learning is used heavily so if you have used an app to book a cab recently then you are already

using machine learning to an extent and what happens is that it provides a personalized application which is unique to you it automatically detects your location and provides option to either go home or office or any other frequent basis based on your history and patterns it uses machine learning algorithm layered on top of historic trip date had to make more accurate ETA predictions now uber with the implementation of machine learning on their app and their website saw 26% accuracy in delivery and pickup that's a huge a point now coming to the virtual person assistant as the name suggests virtual person assistant assist in finding useful information when asked why a voice or text if you have the major applications of machine learning here a speech recognition speech to text conversion natural language processing and text-to-speech conversion all you need to do is ask a simple question like

what is my schedule for tomorrow or show my upcoming flights now for answering your personal assistant searches for information or recalls your related queries to collect the information recently personal assistants are being used in chat pods which are being implemented in various food ordering apps online training web sites and also in commuting apps as well again product recommendation now this is one of the area where machine learning is absolutely necessary and it was one of the few areas which emerged the need for machine learning now suppose you check an item on Amazon but you do not buy it then and there but the next day you are watching videos on YouTube and suddenly you see an ad for the same item you which to Facebook they're also you see the same ad and again you go back to any other side and you see the ad for the same sort of items so how does this happen well this happens because Google

tracks your search history and recommends asked based on your search history this is one of the coolest application of machine learning and in fact 35% of Amazon's revenue is generated by the products recommendation and now coming to the cool and highly technological side of machine learning we have self-driving cars if we talk about self-driving car it's here and people are already using it now machine learning plays a very important role in self-driving cars and I'm sure you guys might have heard about Tesla the leader in this business and the excurrent artificial intelligence is driven by the high rare manufacturer Nvidia which is based on unsupervised learning algorithm which is a type of machine learning algorithm now in media state that they did not train their model to detect people or any of the objects as such the model works on deep learning and trout sources it's data from the other

vehicles and drivers it uses a lot of sensors which are a part of IOT and according to the data gathered by McKenzie the automatic data will hold a tremendous value of 750 billion dollars but that's a lot of dollars we are talking about in now next again we have Google Translate now remember the time when you travel to the new place and you find it difficult to communicate with the locals or finding local spots where everything is written in a different languages well those days are gone Google's G and MT which is the Google neural machine translation is a neural machine learning that works on thousands of languages and dictionary it uses natural language processing to provide the most accurate translation of any sentence of words since the tone of the word also matters it uses other techniques like POS tagging named entity recognition and chunking and it is one of the most used applications of machine

learning now if we talk about dynamic pricing setting the rice price for a good or a service is an old problem in economic theory there are a vast amount of pricing strategies that depend on the objective sort a movie ticket a plane ticket or a Kaffir everything is dynamically priced now in recent year machine learning has enabled pricing solution to track buying trends and determine more competitive product prices now if we talk about uber how does Oberer determine the price of your right Uber's biggest use of machine learning comes in the form of surge pricing a machine learning model named as geo search if you are getting late for a meeting and you need to book an uber in a crowded area get ready to pay twice the normal fear even from flights if you are traveling in the festive season the chances are that prices will be twice as much as the original price now coming to the final application of

machine learning we have is the online video streaming we have Netflix Hulu and Amazon Prime video now here I'm going to explain the application using the Netflix example so with over 100 million subscribers there is no doubt that Netflix is the daddy of the online streaming world when Netflix Petey rice has all the moving industrialists taken aback forcing them to ask how on earth could one single website take on Hollywood now the answer is machine learning the Netflix algorithm constantly gathers massive amounts of data about user activities like when you pause rewind fast-forward what do you want the content TV shows on weekdays movies on weekend the date you watch the time you watch whenever you pause and leave a content so that if you ever come back they would suggest the same video the rating events which are about 4 million per day the searches which are about 3 million per day the browsing and

the scrolling behavior and a lot more now they collect this data for each subscriber they have and use the recommender system and a lot of machine learning applications and that is why they have such a huge customer retention rate so I hope these applications are enough for you to understand how exactly machine learning is changing the way we are interacting with the society and how fast it is affecting the world in which we live in so if you have a look at the market trend of the machine learning here so as you can see initially it wasn't much in the market but if you have a look at the 2016 site there was an enormous growth in machine learning and this happened mostly because you know earlier we had the idea of machine learning but then again we did not had the amount of big data so as you can see the red line we have in the histogram and the bar plot is that of the big data so big data also increased

during the years and which led to the increase in the amount of data generated and recently we had that power or I should say the underlying technology and the hardware to support that power that makes us create machine learning programs that will work on the spec data so that is why you see very high inclination during the 2016 period time as compared to 2012 so because during 2016 we got new hardware and we were able to find insights using those hardware and program and create models which would walk on heavy data now let's have a look at the life cycle of machine learning so a typical machine learning life cycle has six steps so the first step is collecting data second is video wrangling then we have the third step per be analyze the data fourth step where we train the algorithm the fifth step is when we test the algorithm and the sixth step is when we

deploy that particular algorithm for industrial uses so when we talk about the fourth step which is collecting data so here data is being collected from various sources and this stage involves the collection of all the relevant data from various sources now if we talk about data wrangling so data wrangling is the process of cleaning and converting raw data into a format that colors can we need consumption now this is a very important part in the machine learning lifecycle as it's not every time that we receive a data which is clean and is in a proper format sometimes there are values missing sometimes there are wrong values sometimes data format is different so a major part in a machinery lifecycle goes in data wrangling and data cleaning so if we talk about the next step which is data analysis so data is analyzed to select and filter the data require to the model so in this step we take the

data use machine learning algorithms to create a particular model now next again when we have a model what we do is train the model now here we use the data sets and the algorithm is trained on between data set through which algorithm understand the pattern and the rules which govern the particular data once we have trained our algorithm next comes testing so the testing data set determines the accuracy of our model so what we do is provide the test data set to the model and which tells us the accuracy of the particular model whether it's 60% 70% 80% depending upon the requirement of the company and finally we have the operation and optimization so if the speed and accuracy of the model is acceptable then that model should be deployed in the real system the model that is used in the production should be made with all the available data models improve with the amount of available data used to create them all

the result of the model needs to be incorporated in the business strategy now after the model is deployed based upon its performance the model is updated and improved if there is a dip in the performance the moral is retrained so all of these happen in the operation and optimization stage now before we move forward since machine learning is mostly done in Python and us so and if we have a look at the difference between Python ah I'm pretty sure most of the people would go for Python and the major reason why people go for python is because python has more number of libraries and pythons being used in just more than data analysis and machine learning so some of the important Python libraries here which I want to discuss here so first of all I'll talk about matplotlib now what matte lip does is that it enables you to make bar chart scatter plots the line charts histogram basically what it does

is helps in the visualization aspect as data analyst and machine learning ingenious what one needs to represent the data in such a format that it is used that it can be understood by non-technical people such as people from marketing people from sales and other departments as well so another important by the library here we have a seaborne which is focused on the visuals of statistical models which includes heat maps and depict the overall distributions sometimes people work on data which are

more geographically aligned and I would say in those cases he traps are very much required now next we come to scikit-learn and scikit-learn is the one of the most famous libraries of Python I would say it's simple and efficient or data mining and for data analysis it is built on numpy and my product lab and it is open source next on our list we have pandas it is the perfect tool for data wrangling which is designed for quick and easy data manipulation aggregation and visualization and finally we have numpy now numpy stands for a numerical Python provides an abundance of useful features for operation on n arrays which has an umpire race and mattresses in spite and mostly it is used for mathematical purposes so which gives a plus point to any machine learning algorithm so as these were the important part in larry's which one must know in order to do any price and programming

for machine learning or as such if you are doing Python programming you need to know about all of these libraries so guys next what we are going to discuss other types of machine learning so then again we have three types of machine learning which are supervised reinforcement and unsupervised machine learning so if we talk about supervised machine learning so supervised learning is where you have the input variable X and the output variable Y and you use and uncoil know to learn the mapping function from the input to the output so if we take the case of object detection here so or face detection I rather say so first of all what we do is input the raw data in the form of labelled faces and again it's not necessary that we just input faces to train the model what we do is input a mixture of faces and non faces images so as you can see here we have labeled face and labeled on faces what we do is provide the

with the algorithm the algorithm creates a model it uses the training dataset to understand what exactly is in a face what exactly is in a picture which is an order phase and after the model is done with the training and processing so to test it what we do is provide particular input of a face or an on face what we know see the major part of supervised learning here is that we exactly know the output so when we are providing a face we ourselves know that it's a face

so to test that particular model and get the accuracy we use the labelled input raw data so next when we talk about unsupervised learning unsupervised learning is the training of a model using information that is neither classified nor labeled now this model can be used to cluster the input data in classes or the basis of the statistical properties for example for a basket full of vegetables we can cluster different vegetables based upon their color or sizes so if I have a look at this particular example here we have what we are doing is we are inputting the raw data which can be either apple banana or mango what we don't have here which was previously there in supervised learning are the labels so what the algorithm does is that it visually gets the features of a particular set of data it makes clusters so what will happen is that it will make a cluster of red looking fruits which are Apple yellow

looking fruits which are banana and based upon the shape also it determines what exactly the fruit is and categorizes it as mango banana or apple so this is unsupervised learning now the third type of learning which we have here is reinforcement learning so reinforcement learning is the learning by interacting with a space or an environment it selects the action on the basis of its past experience the exploration and also by new choices a reinforcement learning agent learns from the consequences of its action rather than from being taught explicitly so if we have a look at the example here the input data we have what it does is goes to the training goes to the agent the agent selects the in Gotham it takes the best action from the environment who gets the reward and the morale is strange so if you provide a picture of a green apple although the Apple which it particularly

nose is red what it will do is it will try to get an answer and with the past experience what it has and it will reiterate the alcohol time and then finally provide an output which is according to our requirements so now these were the three major types of machine learning algorithms next what we're gonna do is take deep into all of these types of machine learning one by one so let's get started with supervised learning first and understand what exactly supervised learning and what are the different algorithms inside it how it works the algorithms the working and we'll have a look at the various algorithm demos now which will make you understand it in a much better way so let's go ahead and understand what exactly is supervised learning so supervised learning is where you have the input variable X and the output variable Y and using algorithm to learn the mapping function from the input to

the output as I mentioned earlier with the example of face detection so it is cos subbu is learning because the process of an algorithm learning from the training data set can be thought of as a teacher supervising the learning process so if we have a look at the supervised learning steps or what will rather say the workflow so the model is used as you can see here we have the historic data then we again we have the random sampling we split the data enter training error set and the testing data set using the training data set we with the help of machine learning which is supervised machine learning we create statistical model now after we have a model which is being generated with the help of the training data set what we do is use the testing data set for prediction and testing what we do is get the output and finally we have the model validation outcome that was third training and testing so if we have a

look at the prediction part of any particular supervised learning algorithm so the model is used for operating outcome of a new dataset so whenever performance of the model degraded the model is retrained or if there are any performance issues the model is retrained with the help of the new data now when we talk about Super Western in there not just one but quite a few algorithms here so we have linear regression logistic regression this is entry we have random forests we have made biased classifiers so linear regression is used to estimate real values for example the cost of houses the number of calls the total sales based on the continuous variables so that is what ringing a regression is now when we talk about logistic regression it is used to estimate discrete values for example which are binary values like 0 & 1 yes or no true and false based on the given set of independent way so for

example when you are talking about something like the chance of winning or if we talk about winning which can be the true or false if will it train today which it can be the yes or no so it cannot be like when the output of a particular algorithm or the particular question is either yes/no or binary then only we use a logic regression now next we have decision trees so so these are used for classification problems it works for both categorical and continuous dependent variables and if you talk about random forest so random forest is an N symbol of a decision tree it gives better prediction and accuracy that decision tree so that is another type of supervised learning algorithm and finally we have the Nate passed classifier so it is a classification technique based on the Bayes theorem with an assumption of independence between predictors so we'll get more into the details of all of these

algorithms one by one so let's get started with linear regression so first of all let us understand what exactly linear regression is so linear regression analysis is a powerful technique you operating the unknown value of a variable which is the dependent variable from the known value of another variable which is the independent variable so a dependent variable is the variable to be predicted or explained in a regression model whereas an independent variable it's a variable rate the dependent variable in a regression equation so if you have a look here at a simple linear regression so it's basically equivalent to a simple line which is with a slope which is y equals a plus BX where Y is the dependent variable a is the y-intercept we have B which is the slope of the line and X which is the independent variable so intercept is the value of the dependent variable Y when the value of the independent variable X is 0 it is the point at which the line cuts the y-axis

whereas slope is the change in the dependent variable for a unit increase in the independent variable it is the tangent of the angle made by the line with the x-axis now when we talk about the relation between the variables we have a particular term which is known as correlation so correlation is an important factor to check the dependencies when there are multiple variables what it does is it gives us an insight of the mutual relationship among variables and it is used for creating a correlation plot with the help of the Seabourn library which I mentioned earlier which is one of the most important libraries in Python so correlation is very important term to know about now if we talk about regression lines so linear regression analysis is a powerful technique used for predicting the unknown value of a variable which is the dependent variable from the regression line which is simply

a single line that best fits the data in terms of having the smallest overall distance from the line to the points so as you can see in the plot here we have the different points or the data points so these are known as the fitted points then again we have the regression line which has the smallest overall distance from the line to the points so you will have a look at the distance between the point to the regression line so what this line shows is the deviation from the regression line so exactly how far the point is from the regression line so let's understand a simple use case of linear regression with the help of a demo so first of all there is a real state company use case which I'm going to talk about so first of all here we have John he has some baseline for pricing the villa's and the independent he has in Boston so here we have the dataset description which we're going to use so this data set has different

columns such as the crime rate per capita which is CRI M it has proportional residential residential land zone for the Lots proportion of non retail business the river the United Rock side concentration average number of rooms and the proportion of the owner occupying the built prior to 1940 the distance of the five Boston employment centers in excess of accessibility to radial highways and much more so first of all let's have a look at the data set

we have here so one number I don't thing here guys is that I'm going to be using Jupiter notebook to execute all my practicals you are free to use the spiral notebook or the console either so it basically comes down to your preference so for my preference I'm going to use the trippity notebook so for this use case we're gonna use the Boston housing data set so as you can see here we have the data set which has the CRI MZ and in desc CAS NO x the

different variables and we have the data set of almost I would say like 500 houses so what John needs to do is plan the pricing of the housing depending upon all of these different variables so that it's profitable for him to sell the house and it's easier for the customers also to buy the house so first of all let me open the code here for you so first of all what we're gonna do is import the library is necessary for this project so we're gonna use the numpy you're gonna import numpy as NP import pandas at PD then we're gonna also import the matplotlib and then we are going to do is read the Boston housing data set into the BOS one variable so now what we are gonna do is create two variables x and y so what we're gonna do is take 0 to 13 I'll say is from CR I am - LS dat in 1x because that's the independent variable and Y here is dependent variable which is the MATV which is the final price so first of all what we need to do is plot a correlation

so what we're gonna do is import the Seabourn library as SNS we're going to use the correlations to plot the correlation between the different 0 to 13 variables what we going to do is also use MATV here also so what we're going to do is SNS dot heatmap correlations to be gonna use the square to differentiate usually it comes up in square only or circles so you don't know so we're going to use square you want to see you see map with the Y as GNP you this is the

color so there's no rotation in the y axis and we're going to rotate the excesses to the 90 degree and let's we gonna plot it now so this is what the plot looks like so as you can see here the more thicker or the more darker the color gets the more is the correlation between the variables so for example if you have a look at CRI M&M ADV right so as you can see here the color is very less so the correlation is very low so one thing important what we can see here is the tax and our ad which is the full value of the property and RIT is the index of accessibility to the radial highways now these things are highly correlated and that is natural because the more it is connected to the highway and more closer it is to the highway the more easier it is for people to travel and hence the tax on it is more as it is closer to the highways now what we're going to do is from SQL urn validation we're going to import the

train test split and we're gonna split the data set now so what we are going to do is create four variables which are the extreme X test y train white tests and we're going to use a train test split function to split the x and y and here we're going to use the test size 0.3 tree which will split the data set into the test size will be 33% well as the training size will be 67% now this is dependent on you usually it is either 60/40 70/30 this depends on your use

case your data you have the kind of output you are getting the model you are creating and much more then again from SQL learn dot linear model we're going to import linear regression now this is the major function we're going to use is linear regression function which is present in SQL which is a scikit-learn so we're going to create our linear regression model into LM and the model which are going to create it and we're going to fit the training videos which has the X train and the white rain and then we're going to create a prediction underscore Y which is the LM dot credit and you take the X test variables which will provide the predicted Y variables so now finally if we plot the scatter plot of the Y test and the y predicted what we can see is that and we give the X label as white test and the Y label has Y predicted we can see the regression line which we have plotted at the scatter plot and if you want to draw

a regression line it's usually it will go through all of these points excluding the extremities which are here present at the endpoints so this is how a normal linear regression works in Python what you do is create a correlation you find out you split the dataset into training and testing variables then again you define what is going to be your test size import the reintegration moral use the training data set into the model fitted use the test data set to create the predictions

and then use the wireless core test and the predicted why and plot the scatter plot and see how close your model is doing with the original data it had and check the accuracy of that model not typically you use these steps which was collecting data what we did data wrangling analyzed the data we trained the algorithm we use the test algorithm and then we deployed so fitting a model means that you are making your algorithm learn the relationship between predictors and the outcomes so that you can predict the future values of the outcome so the best fitted model has a specific set of parameters which best defines the problem at hand since this is a linear model with the equation y equals MX plus C so in this case the parameters of the model learns from the data that are M and C so this is what more fitting now if it have a look at the types of fitting which are available so first of all machine learning

algorithm first attempt to solve the problem of underfitting that is of taking a line that does not approximate the data well and making it approximate to the data better so machine does not know where to stop in order to solve the problem and it can go ahead from appropriate to overfit moral sometimes when we say a mall or fits a data set we mean that it may have a low error rate for training data but it made not generalize well to the overall population of the data we are interested in so we have under fact appropriate and over fit these are the types of fitting now guys this was linear regression which is a type of supervised learning algorithm in machine learning so next what we're going to do is understand the need for logistic regression so let's consider a use case as in political elections are being contested in our country and suppose that we are interested to know which candidate will

probably win now the outcome variables result in binary either win or lose the predictor variables are the amount of money spent the age the popularity rank and etc etcetera now here the best fit line in the regression mower is going below 0 and above 1 and since the value of y will be discrete that is between 0 and 1 the linear I in to be clipped at zero and one no linear regression gives us only a single line to classify the output with linear regression our resulting curve cannot be formulated into a single formula as you obtain three different straight lines what we need is a new way to solve this problem so hence people came up with logistic regression so let's understand what exactly is logic regression so logistic regression is a statistical method for analyzing a data set in which there are one or more independent variables that determine an outcome and the outcome is a binary class type so

example a patient goes a followed a teen checkup in the hospital and his interest is to know whether the cancer is benign or malignant now a patient's data such as sugar level blood pressure eight skin width and the previous medical history are recorded and a doctor checks the patient data and determines the outcome of his illness and severity of illness the outcome will result in binary that is zero if the cancer is malignant and one if it's been eying non-autistic progression is a statistical method used for analyzing a dataset there were say one or more dependent variables like we discuss like the sugar level blood pressure each skin with the previous medical history and the output is binary class type so now let's have a look at the lowest aggression curve now the law disintegration code is also called a sigmoid curve or the S curve the sigmoid function converts any value from minus infinity to infinity to the discrete

value 0 or 1 now how to decide whether the value is 0 or 1 from this curve so let's take an example what we do is provide a threshold value we set it we decide the output from that function so let's take an example with the threshold value of 0.4 so any value above 0.4 will be rounded off to 1 and anyone below 0.4 we really reduce to zero so similarly we have polynomial regression also so when we have nonlinear data which cannot be predicted with a linear model we switch to the polynomial regression now such a scenario is shown in the below graph so as you can see here we have the equation y was three X cubed plus 4x squared minus 5x plus 2 now here we cannot perform this linearly so we need polynomial regression to solve these kind of problems now when we talk about logistic regression there is an important term which is decision tree and this is one of the most used algorithms in supervised learning now let us understand what exactly is a decision

tree so our decision tree is a tree like structure in which internal load represent tests on an attribute now each attribute represents outcome of test and each leaf node represents the class label which is a decision taken after computing all attributes apart from root to the leaf represents classification rules and a decision tree is made from our data by analyzing the variables from the decision tree now from the tree we can easily find out whether there will be came tomorrow if the conditions are rainy and less windy now let's see how we can implement the same so suppose here we have a dataset in which we have the outlook so what we can do is from each of the outlooks we can divide the data as sunny overcast and rainy so as you can see in the sunny side we get two yeses and three noes because the outlook is sunny the humidity is normal and the wind is weak and strong so it's a fully sunny day

what we have is that it's not a pure subset so what we're going to do is split it further so if you have a look at the overcast we have humidity high normal week so yes during overcast we can play and if you have a look at the Raney's area we have three SS and - no so again what we're going to do is split it further so when we talk about sunny then we have humidity in humidity we have high and normal so when the humidity is normal we're going to play which is the pure subset and if the humidity is high we are not going to play which is also a pure subset now so let's do the same for the rainy day so during rainy day we have the vent classifier so if the wind is to be it becomes a pure subset we're going to play and if the vent is strong it's a pure substance we're not going to play so the final decision tree looks like so first of all we check if the outlook

is sunny overcast or rain if it's overcast we will play if it's sunny we then again check the humidity if the humidity is high we will not play if the humidity is normal we will play when again in the case of rainy if we check the vent if the wind is weak the play will go on and similarly if the wind is strong the play must stop so this is how exactly a decision tree works so let's go ahead and see how we can implement logisitics regression in decision trees now for logistic regression we're going to use the Casa dataset so this is how the dataset looks like so here we have the ie diagnosis radius mean texture mean parameter mean these are the stats of particular cancer cells or the cyst which are present in the body so we have like total 33 columns on the way started from IDE to unnamed 32 so our main goal here is to define whether or I'll say predict whether the cancer is been eyeing on mannequin so first of all what

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent