Hello, guys, and welcome back to the class, of course, for the complete introduction to data science.
So in this class, we are going to talk about machine learning.
So in the past class, we talk about what is it in general, how it works and basically all the basics
of this.
In this class, we are going to talk about the different machine learning algorithms.
So we're not going to go into practice of those algorithms.
We are going to cover all the theoretical part.
So I'm going to talk about each of those.
Well, each of the of the most important machine learning algorithms, how they work and simply give
you a brief introduction to each of those algorithms.
Once again, my goal is not that you guys become professional in all this, but simply that you understand
what is it how each of those algorithms works and basically all that you can do with machine learning
and Python as well.
So it's not waiting more.
And let's jump right into it.
All right.
So we see the first machine learning algorithm that we are going to talk about will be linear regression.
And this one is pretty simple to understand.
So basically, the formula is Y equal to X plus B. So basically, as you can see on the graph right
here.
So what exactly is the linear regression in machine learning?
It's simply a supervised machine learning algorithm where the prediction output is continuous and has
a well, we can say concrete sloup.
Basically the slope is pretty much the same since it's Y equals X plus.
So basically an example of machine learning regression could be the graph right here.
So we can say, for example, that right here we have the price paid for, for example, let's say a
plate.
So let's say in the restaurant you guys are buying something and this would be the price paid for your
dish or for what you have paid.
And this would be the amount of thip of that you guys have left to basically, as you can see, this
would be our well, our test.
So the system will be able to tell us that the more someone buys the well, the more the plate is expensive,
the more the person will leave a tip.
So the more the tip will be high.
So basically, as you can see, and there would be right here, we will have a in the middle.
We'll have our food that will be right there.
So you can see it's it's drawing right here.
So basically, this would be like the average or the mean.
Basically, it's in the middle of all the points.
Some linear regressions are, well, better than others.
So in some of them, you will have points everywhere.
And some of them, the points are very, very well condensed in one place.
Those are more representative.
So basically a soup like this would be more representative that if we have points everywhere and there
is one soup in the average, it's not really representative.
So this is for linear regression, the same type of algorithms that we are going to be the logistic
regression.
And it's not like linear regression.
Basically, this is a logistic regression.
Well, it comes from statistics like the linear regression, but it's not that long ago riddim for regression
problems.
In other words, problems that require the prediction of a continuous outcome.
So basically, it's not for this absolute logistic regression is really a method that is used for binary
classifications.
In other words, one or zero.
So it will give you a discrete binary outcome between zero.
And so, as I said.
So if we want to think about something so basically we can have well, as an example, we can, for
example, say, do you like to eat outside to basically asking someone that if he likes to eat outside,
yes or no, I could be a logistic regression and zero in the square?
Well, yes, let's say yes in this case will be zero and no in this case would be one.
So basically it will look something like this.
So you can see all will have zero right here and we'll have one right here.
And after that, we will have an average and this would be our outcome.
So we see the majority of people like to eat outside if it's closer to one, because one is yes and
zero is no.
So basically, this is another type of regression that we can use in machine learning.
But once again, this one is really, really important, like the first one.
And the difference between linear and logistic is that logistic is really between zero and one.
So this is more of a binary.
Well, the outcome that you will have will be a discrete binary outcome, not like the linear regression
to the algorithm that we are going to talk about in this class is pretty.
It's called the decision tree.
So I think we already talked about this type of algorithm at the beginning of the course basically about
decision trees and other stuff related to this.
So basically, what exactly is a decision tree?
So basically, decision trees well, in general are constructed via an algorithm approach that identifies
ways to split a dataset based on different conditions.
So basically, we will have different conditions for different variables that we will need to take input
into consideration to be able to create our decision tree.
So it's once again one of the most used and practical methods because it's really based on how we as
human beings solve our problems.
So basically, let's take an example.
So the example right here that we have.
So once again, this is a decision tree that will help us know what animal we are talking about.
So basically, the first question that we are going to ask is, does he has feeder's if yes.
Can he fly?
If no, has he fins?
If he can fly that sandhog?
If he can fly, that's a penguin if he has fins.
Well, that's a dolphin.
If not, that's a beer.
Once again, this is a really basic decision.
Trees are almost everywhere.
So basically, when you guys go, for example, to buy food, let's say you guys are going to buy a
pizza.
So basically you will find decision trees when you will buy your pizza for the purposes of buying a
pizza.
Could be a decision tree.
So as you can see, this is really, really used everywhere or no.
So not only buying a pizza, so we do it without even thinking about it.
And implementing this inside of a machine or inside of a system can be something that is there could
be really, really useful in all aspects of our life.
And, well, in general, simply having this inside of a system can be really useful and make the system
more optimized and performant.
Right.
Another type of algorithm that we are going to talk about today will be the support vector machine,
which is one really interesting, one really interesting algorithm.
So basically, this is a supervised machine learning algorithm that can be used for classification or
regression.
But this this algorithm is mostly used for classification purposes.
So what does this mean?
It's pretty simple.
So support machine is spread vector machine algorithm is able to generalise between two classes that
are different if the set of labeled data is provided in the training set up.
So basically, if we provide enough data in the training set of Yalgoo, I'm so basically the goal of
this algorithm or the support vector machine algorithm will be to find a hydroplaned in an N dimensional
space where and is the number of features.
So basically we have features right here and in the end to be able to separate the two classes of data.
So basically we have the two classes right here and there is a multitude of possibilities of hyper playing
that can be chosen.
Basically, it sounds a little bit complicated and you guys maybe don't see where exactly can be applied
in real life.
So let me just give you two examples.
Let's say, for example, you want to create a facial expression classification model.
So let's say this model will say the person is said happy.
I don't know.
The person is surprised, the person is shocked or whatever.
Well, basically, you will use a support vector machine algorithm to be able to build this.
You can do this with this type of algorithm or another thing that will be, for example, text classification.
So basically you will compare a text written by a human being in a text written by a machine or simply
being able to translate a text written by someone to a computer.
So basically to work, for example, a good way to do that will be by using the support vector machine
that will be able, with training, of course, to will be able to spot this type of text and simply
transform it.
So basically, there are plenty of tasks that the SVM algorithm will the SVM model or the SVM algorithm
can realize, and it can be really useful for machine learning purposes.
All right.
Another algorithm that we are going to talk about today will be the night base.
So basically this is another algorithm that is really, really used in machine learning.
So what exactly is Navales?
So this is a classification technique that is based on base theorem.
So basically.
To be able to work with it, you need to understand the basic theorem so it will assume that there is
an independence among predictions predictors.
So they always assume that the presence of a particular feature in a class is not related to the presence
of any other feature.
So this is basically the main reason why it's called naïf.
It's it will take some features and it will use those features to be able to say, for example, OK,
this is, I don't know, a PDA, for example.
So let me just give you a quick example.
So let's say something is around with 500 grams and has the different colors on it.
So basically the theorem will say, OK, well, this algorithm will say, OK, this is a piece.
So basically all the attributes of that, I said have the attributes of the pizza, for example.
And so even if it's not necessarily making sense, so it could be, for example, a cake.
It could be, for example, I don't know any other thing that is around with some colors on it.
So basically, this is why this is the main reason why it's called naive.
But once again, it could be really useful in classification and as well as to understand some other
things.
So basically, it's a well, it's a one of machine learning models.
And basically, if it's here, it's because it does a great job.
So basically, how is how many of these words?
So just to give you a small introduction to how it works, you not necessarily need to understand that
100 percent.
So basically, you will start with calculating the calculation of all prior probabilities for a given
class label, and then you calculate all conditional probabilities with each attribute for each class.
Then you will multiply some class, some classes, conditional probabilities.
You multiply prior probabilities with the number, the step three probabilities.
And finally, you will understand what class belongs to the given input that sets them, which in other
words, is the class that is with the higher probabilities.
So you can have an example right here.
All right, the next step of algorithm that we are going to talk about in this class will be the and
then or the key nearest neighbor.
So we say this is pretty simple to understand.
So what exactly is this machine learning algorithm?
So the key interesting algorithm is a type of supervised machine learning algorithm.
So basically it can be used for regression, predictive problems, as well as for classification problems,
but it's mainly used for classification, predictive problems.
So basically it's mainly used for this, but it can be used for both of them.
So it could be used for classification as well as regression problems, but it's mainly used in classification.
So the Kinect algorithm has no specialized training phases and is using all the data for training while
classification.
So this is why it's really known as a lazy algorithm.
So basically lazy learning algorithm.
Sorry.
So this is one of the main reasons of why the and then doesn't assume anything about underlying data,
that is that is why it's also considered a non parametric learning algorithm.
So basically, if there are there is two things that we can well say about the CNN algorithm is that,
first of all, it's elizee learning algorithm.
And finally, it's a non parametric learning algorithm.
So it can be used in many, many places in real life.
So this is one example.
So basically, it's loans.
Well, we have variables.
We have the variable long.
We have the age here at variable, not default and defaults, which basically the person have paid for
it, yes or no.
And this kid will use the distance between this point for any other point and the neighbors of this
point.
So basically, the neighbors of this point, the closest neighbors will be this one, this one, this
point in this point.
And we are able to come to certain conclusions with this algorithm at the end.
All right.
Another type of algorithm that we are going to talk about today will be the key means algorithm, which
is a well known unsupervised learning algorithm that is used with machine learning.
So basically, what exactly is the key means algorithm?
So it's very simple.
As I said, it's an unsupervised learning algorithm that is used to solve clustering problems.
So basically, this Ugwu is used well, uses a very simple yet powerful procedure to classify data to
a certain number of clusters called K.
So basically K is a cluster.
So the way it works at first we find the number of clusters and we assume where is the center of these
clusters?
So basically we don't know where exactly is the center.
So we make an assumption at first.
We see that's the first thing we are doing when we have identified them.
Then we can take any object or the first key object as initial center.
So basically to be able to find the center, well, not to find, but to assume a certain center.
This is how we will do it.
And then the key means algorithm will do the first.
Well, what it will do at first, it will determine the send the central coordinates, then it will
find the distance of each object to the center and finally group all the objects based on, well, the
minimum of the minimum distance or.
So if we well, usually look something like this, as you can see here, all the objects are grouped,
grouped together and to be able to understand a little bit more.
Let's talk about some real life example.
So basically, this machine learning algorithm could be used in plenty of ways.
So some of the examples in which we can use it in real life can be, for example, document classification.
So basically we can classify different documents in different places, for example.
So this could be a really interesting way to use this algorithm.
Another thing, for example, could be customer segmentation.
So basically dividing customers into different, well, types of customers, for example, customers
that spend a lot of customers that use, I don't know, credit cards, customers that use debit cards.
Customers that spade a spade.
Cash customers.
That comes once a week.
So really, you can really Sigmon segmented your consumers and another way, for example, insurance
fraud.
So basically finding anomalies into, well, insurance contracts, for example, or people who are trying
to front entrance.
And so basically, there are plenty of ways that you can flood insurance.
So basically, people who FROGH insurances, it's possible to well, to to be able to make a detection
of those frauds by using the ketamine's algorithm.
All right.
So the other thing that we are going to talk about in this class would be the random forest algorithm,
which is once again another really powerful algorithm that is used in machine learning.
So for those of you who don't remember, we talked at a little bit at the beginning of this class about
decision trees.
And this is exactly what it's the same county, the same concept.
So it's a concept of decision we just made bigger.
So let me explain.
So basically, Random Forest is a supervised machine learning algorithm that is used for classification
and regression.
So it can be used for both, but it's mostly used for classification problems.
This algorithm works with decision trees and there is trees in the algorithm.
Well, the more there are trees in the algorithm, the more the forest will be robust.
So in other words, here, for example, we have four trees.
So it's more powerful than if we have tree trees, but not more powerful if we have five.
I exactly where it's basically you have decisions that are made in each tree.
So basically decisions are made in each tree and it has to have the same outcome.
So basically each tree needs to have a certain outcome.
So basically choosing between A, B or C and basically each tree will choose based on different well,
different mapping will choose a different outcome.
So basically, the most trees, the more trees you have that choose a certain outcome, well, the more
this outcome will be reduced or strong and the more there are chances that this outcome is the best
outcome that you can have based on the well, based on the random forest indifference that if we only
choose only work with one decision tree, we only have what we only will know.
What is the be the best decision based on one decision tree?
But with a random forest, we are able to know how.
What is the best decision based on many trees that will each of them, each of them will map different
scenarios in different situations.
And at the end this will be a we better well, we better wait to find out the best answer to a problem.
So instead of using only one decision tree using a complete random forest.
So if we want to think about it in a certain way.
So basically, this is just.
A decision tree that is upgraded so we can see it this way, so basically it's more than one decision
and it's more than one decision.
So this will simply confirm our answer that we have in one.
All right.
So I hope you guys right now understood all the different types of algorithms that exist in machine
learning.
So those are just the examples of the most used and even the most simple.
So once again, I'm not expecting you guys to become a professional.
So this is just a brief introduction.
I can spend hours talking just about each of those algorithms with all the mathematical and statistical
aspect of each of them.
So I try to be as straight to the point as possible.
So right now, guys, you have a complete idea of different algorithms that exist in machine learning.
So class goes into our next class.