Now let's discuss about the aggression.
So let us assume that this is the of which we have in time and we have only one input variable, which
is the education.
And based on this education, we want to predict the income of the.
Now, we can predict these by creating a linear regression and what linear regression suggests is that
we will be drawing a particular line such that the line will be able to map all the values if possible.
So just as you what lions can we create here?
There could be a line created like this.
There could be another nine.
Created like this.
And there could be another line creator.
Like this.
Now, each of these lines will be able to capture some of the data points, but none of the line is
actually happening, capturing most of the data.
So we have to find out which line will be able to capture maximum data points.
So we will be finding the error which is present to you.
Now let us see how will we find out if the values I correctly predicted or not?
So for finding out if the values are predicted correctly or not, we will be dropping a perpendicular
to each data point to find out the distance or the error value.
So let us consider that this is the line.
Which we have actually created for the Swedish.
So when we are dropping the ball, when Nikolas.
The distances will be this.
This.
And this.
Now, let us compare the distances now, these instances when compared to distances from this particular
line.
Will be a lot more so the distances for this particular line will be larger than the earlier one.
So let me drop distances to this particular line.
So if we drop the distances here, the distance would be less.
Hear the distance would be less here, the distance would be less.
This is same.
Now, after this point, all the distances will be more than the previous distance.
So you can see that in comparison with these two lines, this first line actually provides a better
result.
So we will be creating the front lines and we will be comparing the distances between these lines.
So how will it be creating these lines and how we will be reducing the distance is the next thing in
my.
So let us try to solve this and let us try to see that, how will we actually create this equation of
this line and how will we create this model?
So what are the different type of equations which we have, there are limited equations, quadratic
equations, Kubic equations, so a linear equation.
Will look something like this.
And this equation will be something like, why is it going to be one x one plus two plus B three x three
plus B for export and so on?
And in the end, one constant V will be added to it.
Because the original line of formula is Y is equal to a mixed blessing, which is the original equation
for line where C is the.
Intercept and M is the slope.
Similarly, we will be creating this particular equation because here we have multiple X values, let
us get back to the data which we have.
So this is the data which we have, so the age amount, salary dependent sex and children will be different
X values, that is X one, two, three, four, five.
And the interest rate will be the value which we are predicting.
So the equation will be some confusion multiplied with E under the age and a definition multiplied with
amount on a double multiplied with salary under the compulsion to multiply the dependent on the condition
multiplied by six, another coefficient multiplied by children and some of all of these.
Should be equivalent to the value of Interest-free now out of this, the only thing which we need to
find out is the value of the efficient because value.
And the one, two, three values is something which we already have, so the only thing which we have
to formulate is the value of BE1 be to be three before and so on.
Now, while we are creating this equation, we have to make sure that the prediction, which we are
making good predictions.
So what are different features of a good prediction?
So a good prediction model will give accurate results.
So a good model will give accurate results.
So a model which will build this particular equation will be a better model in comparison to the model
which will give this particular equation.
Next is the accuracy should not be limited to just one data point.
So let us say we are looking at a particular city for which we are trying to find out how much water
or how much food is needed in that particular.
And similarly, we are looking for multiple cities in the country.
So now our task is to find out the amount of food required as accurately as possible so that no specific
city doesn't have extra food or no specific city has lesser amount of.
So we're going to have to make sure that all the cities have sufficient amount of food available so
that no one dies of hunger.
We cannot do something like we predict one requirement for one particular city correctly, and the predictions
are very wrong or very inaccurate for the other cities, because in that case, other cities, the people
who are living in other cities will die of hunger.
Right.
So the predictions which we are making have to be in sync and accurate or good enough for all the data
points or at least for the maximum number of data points.
So now the model which we will be creating, the model which we will be creating or the predictions
which we will be making, should be performing equally well on the testing data as on the training data.
Now.
As of now, we don't know what testing device and what printing device, so let us try to understand
that a little.
So let's take the example of preparing for examination again.
Now for an examination we are preparing from a particular information or from a particular book.
Now, this particular book is the invasion force material, which we have now, what happens is the
book will have certain questions at the end of each and every chapter.
So when we are learning from this particular book, we will be practicing on those practice questions,
which we will be having at the end of each and every chapter.
So when we will be doing self evaluation, while we will be training ourselves to give the exam, we
will be self evaluating ourselves on the basis of these practice questions which are present at the
back of the book.
So we will be able to perform really well if we are really studying hard.
We will be able to perform really well on the training data.
That is, the evaluation questions or the practice questions is in the back of the book.
So now the testing data is basically the exact exam, the exam, which we will be giving Igby after
tomorrow, then we will have 14 questions, which will be not present in the book, but we will be based
on the concept which are present in the book.
So when we are learning from the data and we are learning from the information which is provided to
us, we want to perform well on the training data or on the practice questions also.
And we are performing good on practice questions, but we also want to perform well on the final examination
on.
So this is what it means, that it should perform equally well on the training data, that is a practice
question on the testing data, which is the final evaluation, so that if this.
A woodmore.
Now, next thing is that a simpler model is a better model, complex models than do or would Woodfork.
Now let's ignore what Overfitting means.
OK, let us ignore what Overfitting feels for now.
Five.
Just try to understand that we want to make our model as simple as possible.
And what complex model does we will look at in something so far?
Now the model should give accurate results.
The accuracy should not be limited to just one data point.
It should perform equally well on the testing data as on the training data.
And a simpler model is better model than the complex model.
Now, let us see what this regression so did not what we have discussed is that regression is when we
are trying to predict the continuous value.
So regression takes a group of random variables to be predicting why?
I'm trying to find a mathematical relationship between them.
So this relationship is typically in the form of a straight line that best approximates all the individual
data points.
So what this means is that I have certain data, I have certain data, the gardening, education and
income, so I want to set up a relationship between the education and the income of the person so that
for when the next time someone tells me that this is their education, then I can easily guess what
their income would be.
So what is needed aggression, linear regression is used for continued static good values like Ege,
sales interest, industry or house prices.
So we can let us see if we can have data related to the number of bedrooms, the number of bathrooms,
the the floor of the building and the details, the location of the building, and based on that, we
will try to find out what is what should be the price of the house.
Similarly, we can get details about a person's height and weight and try to predict that age.
So these are different things which we can predict.
So when we are trying to predict a continuous value, then it is called the linear regression from.
Now, what is the expectation, the expectation is too long, the relationship between the independent
input data and the dependent on good values, the independent input data is the legacy for the for the
loan problem.
The independent data could be the age of the person, the gender of the person, the amount which the
user is requesting the loan for the number of dependents.
So all of these will be the.
Independent input data and independent target value will be the interest rate, which we are trying
to predict.
Now for finding out this will calculate the slope and the positions to create a linear equation which
could align do given data property.
So we want to create a linear equation.
So the equation consists of the slope and the.
Coefficients of the values.
So that is what we are trying to predict here.
And in this entire thing, we want to minimize the cost.
Now, let us try to ask you, what exactly is a predictive word like we have discussed about what the
question is?
But our main concern here is to know what caused this.
We want to understand what the cost is.
So how will we understand what is cost?
So to understand the cost, we have to understand what our predictive models.
So for us, a predictive model is just like the application or just like a box in which we provide our
training data.
So we will provide the training data, which is the independent input data and the dependent that it
values, and we will provide it to this box, which we have, and then this box will try to decrypt
the relationship between these independent, independent variables.
So it will try to establish a relationship between this and a group that I do for you to function internally
so that it will apply that function or it will apply that equation on top of these X values.
And using this equation, it will be able to find out the Vivan.
So when we are planning the model or when we are letting the machine learn from the data, we are basically
providing the input data and the output data, the input X values and the output values to the machine.
And the machine will try to find old patterns in the relationship from the state of digitize and create
the equation in.
And then once this equation has been created, then what happens is whenever I have any of the problem
in hand, whenever I have any other input data, again, I can just provide this input data to the machine
and it will apply the formula on this data and automatically provide me the output value as a prediction.
Now, when it is providing me this output data is a prediction, this output data, which is very hard
to value, will not be exactly the same as the value which is expected.
OK, the value which we have, the value which we are predicting will not be.
Exactly the same as the value which is in the real life scenario.
So what do we do now, this gap, this difference between the original value and what we have predicted?
So, for example, we are trying to predict the height of a person.
And so when we are creating a model, we will have given some detail about the person and the height
of the person to the model.
So now the model will try to analyze the characteristics of the person and it will find try to find
out the relationship between the characteristics and the height of the person.
So it will try to do that by creating information internally.
Now, while it is creating the equation internally, it means that I do think the equation to the data,
which it already has.
So it will try to check for the data again.
So it will at one moment it will learn from the data.
At one moment it will learn from this data on this value of the interest rate, and later it will try
to predict this increased interest rate.
So it will try to practice again.
You remember the example for the book, so it will try to evaluate itself based on the questions on
the back of the chapter.
So this jocking from the back of the job, though, so we try to find out what is the exact sort of
the question and what answer has the machine given to us and the difference between the exact answer,
the actual answer and the answer, which the machine has given, is called the error.
It is the editor value between the actual design and what the machine has predicted.
And when we add on the edit for all the observations, because we will not have just one observation
rate, we will not have just one practice question, there will be multiple practice questions.
So then we will be evaluating on all the practice questions, the added value for all the questions
will be summed up, and that is the cost of the model.
That is called the cost of the model, which is the sum of all the ED films and.
Reveals just one particular error, though, I guess, is to reduce the entire cost that invasion cost
might reduce by reducing land value also or by a cumulative reduction in all the edibles.
So our target is to reduce the cumulative Edwardo instead of reducing the error for just one.
But because if we are reducing the error for just one value in that case, the for other values might
increase.
So we don't want that.
We want to reduce the overall.
So let us see, so we have this right is equal to a forfeit, so we have different X values.
So out of those different X values, we want to find out a function which we give right as the output.
So this function is actually the linear equation which we will be forming.
So the equation will be doubled plus the next one plus B, that extra plus Lusby, that's been too three
plus wait for export and so on.
So why is actually that target value, for example, it is the price of the flight ticket or height
of the person or the interest rate, which we are trying to find out, which is the fundamental value.
I'm the one extra extra export, these are the independent values or the features or the attribute,
which is the values which we provide so that the relationship between these values and this value can
be found.
So what are these values?
These values could be season or decision destination, the nearest holiday date.
So these kind of events which actually impact the value of the target value.
And when we are having the training, they originally Devinder X values are already present with us.
So we already know what the V and X values are, hence the lion X value constant.
And then we try to say to various be the values we want to bring, bring the predictions closer to the
actual value.
Now, the value, which we predict is very.
So when we subtract Vizag from the actual value, we get the added value.
So we have sold in value, which we have predicted and subtracted from the actual value.
And this is all the added value.
So in this equation, we already know what is we already know what makes one extra extra is we only
need to find out the be done all be done.
That will be that revalues.
So what is the process, the process will be to convert all the variables into numerical, whether they
are or the that they are categorically that we will have to convert all these variables into numerical.
And after that, the categorical variables should be converted into that many variables.
We have to remove the outliers in the data.
And in case there are any missing values, we will have to imbue those basic values by.
Placing the mean value or the median value in the people?
Once we have done this, the transformations made to bringing data should also reflect in the testing
data.
So whatever transformation we will be doing, all the training data, the same information we will be
doing all the testing, the.
Because the machine does not really know what the interest rate is or what the age of a person is,
the machine will not understand what the machine will only understand what the numbers are.
So it will simply apply the same operations on the numbers which see sees in the training data, all
the lines which it sees in the testing data.
So that is the reason why the transformation's, which are made in the training data, should be made
in the testing data so that the formula which the machine has created should be applicable on both the
six.
Metrics are the types of measures which are used to evaluate the more so different type of things,
that might mean square error and the mean absolute.
So you mean square?
And it is doing that would also mean squared error.
I mean, of the absolute is.
And why have the applied, the squared and the absolute value.
This is because there is no detection in the.
We will understand this in a while, but for now there is no specific direction in the error.
That is why we use one square and the mean absolute and the goodness of the predictions would depend
on the scale of the target values.
So if we are trying to predict how good the values, how how would our predictions.
So that is not something which will be decided on our own basis, but it will be decided on the scale
of the data.
So let's say we are walking with some chemicals, we are working in a chemical industry and we have
to create some products based on that.
So when we are working on a chemical industry and we are creating a particular kind of company or some
specific kind of chemical.
So in that case, even a small millimeter or small animal of the chemical can change the composition
of what we think is right when we are looking in a legacy soil the packaging industry, so that if we
are dealing with gallons or we are dealing with tons of salt, then small milligram of salt will not
make a difference.
So you see, it is depending on the target value.
What exactly are you dealing with?
The scale of the production will change.
So if the production value is off by, what, even one million, the chemical industry, it will cause
a lot of issues.
But if the prediction is off five, five, five grams or 10 grams in the packaging industry, then it
will not make much difference.
So this is what witness prediction?
So now let's say we have the actual price as a thousand nine eighty nine fifty one thousand twenty one
thousand fifty, and we have predicted the prices using the formula.
And these are the predicted prices, which we have.
Now, these predicted prices, you can see the difference between this is the difference between diesel
will be.
Here, the differences here.
The differences mistake here, the difference is minus Hundert.
So now if I have these errors, if I add these errors, the sum comes out to be only 10.
But that does not mean that the issue is of only the.
The editing is actually of 371, but because these negative signs are being canceled out, the edited
out the week, that this is the reason why they need to consider the absolute leader, the absolute
edit will actually keep in consideration all the added values, whether it is a negative or positive
it.
So the main focus and predictive analysis is to reduce the overall.
Not what is the overall rate of the overall and it is VITAC.
This is the revenue which is generated from the function which we have applied, so the added value
will be via minus by half and the sum of all the other values will be the cost of the.
Model, which we have done.
Now, us have a look at this, so this is the input value.
This is the model which we have generated, so this input value of input into the machine learning model
should have already should have generated value, but because our model is not perfect, so it will
generate a value.
Right.
So this is the actual output and this is the predicted.
This is what we have predicted.
So the added value will be the actual value.
And predicted values difference, so we will find out the difference between the value and the actual
value, and that is the added value.
And then we will add these added values after applying the absolute function or by squaring these values
so that the clients do not actually cancel out the devil values.
So here we have a block.
This plot is between height and weight, so you can see there is a positive relationship between height
and weight, so as the height increases, the breathing freezes.
So we have the situation of like.
Between height and weight.
And then there the line intercepts that Y-axis is called the intercept.
And the scale of the equation is change of five divided by the changing X.
This is called the slope of the equation.
So the equation will be very easy, equal to.
The school into X plus that B double, so this is the creation of the line, which we have, that is
why is equal to a mixed blessing where M is the slope, X is the X value, and C is the intercept where
the point intercept the Y axis.
In the next section, we will discuss about the cost and the function.