Well, hello, my dear friends, welcome back, it's good to see you again.
So you remember our previous lesson, we talked about supervised learning methods.
Now this lesson, we're going to continue with supervised machine learning methods.
So I want to get started.
So we have yet another supervised learning algorithm.
Its name is Naive Baz.
The naive Bayes algorithm is based on Bayes theorem, and if you're not familiar with it.
What is it?
Well, look into it.
So Bayes Theorem goes like this, it's the conditional probability calculation formula.
Found by Thomas Bass in 1812, Bayes Theorem is an important topic, studied in probability theory.
That the arm shows the relationship between conditional probabilities and marginal probabilities within
the probability distribution for a random variable.
For example, if the risk of developing health problems is known to increase with age, Bayes Theorem
allows the risk to be an individual of a known age to be assessed more accurately than simply assuming
that the individual is typical of the population as a whole.
Here, let's set it up.
So here's the formula.
So here.
Is the probability of event A when Event B occurs?
This is the probability of occurrence of the a event.
This is a probability of event B occurring when the event occurs.
And this is the probability of event B occurring.
OK, so now we can talk about the algorithm.
Now, eBay's algorithm is it's a lazy learning algorithm.
It can also work on unstable data set.
So the way the algorithm works calculates the probability of each state for an element and classifies
it according to the one with the highest probability value.
So with a little training data, you can do very successful jobs if a value in the test set has an unobservable
value in the training, it gives zero as a probability value, which means it cannot predict.
Right, you've heard of this, this is the condition commonly known as zero frequency.
Correction techniques can be used to resolve this situation, and one of the simplest correction techniques
is known as LaPlace estimation.
Now, you've based classification aims to determine the class that is a category of data submitted to
the system with a series of calculations defined according to probability principles.
So in the naïf based classification, a certain amount of tort data is presented to this system, for
example, one hundred.
The data submitted for training must have a class category with the probability operations performed
on the train data.
The new test data submitted to the system are operated according to the probability values previously
obtained, and then it tries to determine the category of a given test data.
Now, of course, the greater the number of trained data, the more accurate it can be to identify the
true category of that test data.
But you see where we're going with this, right?
The based classification method can have many uses.
But how it is classified is more important than what is classified here.
So the data to be trained can be binary or text where rather than data type and what is it what kind
of proportional relationship we establish between these data, that's what becomes important.
All right, so let's try to understand a simple example here, so we've got some data and it shows us
the weather and how it corresponds to gameplay.
So now we need to clarify whether players will play or not based on weather conditions.
All right.
So we're going to follow the Bullo steps here and we'll perform it step one, or convert the data set
into a frequency table.
Step to create a likelihood table by finding the probabilities like overcast probability, which here
equals point to nine and the probability of playing is point six for.
Step three now, we'll use the naïf Bayesian equation to calculate the posterior probability for each
class.
The class with the highest posterior probability is the outcome of prediction.
Players will play if the weather, Sunny, is a statement, correct?
Well, we can solve it using the method that we discussed earlier of posterior probability.
P Yes, sunny equals P Sunny.
Yes, times P, yes, divided by P Sunny.
So here we have Sunny.
Yes, equals three divided by nine equals zero point three three peace sunny equals five over 14.
Equals point thirty six P, yes, equals nine over 14, which equals point six for now, P yes, sunny
equals point three three times point six for over point thirty six, which equals point six zero, which
has a higher probability.
Yeah, so now you've baize uses a similar method to predict the probability of different class based
on various attributes.
So this algorithm is mostly used in text classification and with problems having multiple classes.
So what do you think?
Are there any pros and cons?
Well, let's look at the pros first.
It is easy and it's fast and predicting class of test data sets, it also performs well in multiclass
predictions.
And on the assumption of independence holds, a naive based classifier performs better compared to other
models like logistic regression, and you also need less training data.
It does perform well in the case of categorical input variables compared to numeric variables.
For numerical variables, normal distribution is assumed bell curve, which is a strong assumption.
And of course, the cons, if a categorical variable has a category in test data sets, which was not
observed in the training data sets, then the model will assign a zero or zero probability and it'll
be unable to make a prediction.
And what do you know that's often known as zero frequency?
Now, to solve this, we can use this smoothing technique, which is one of the simpler things to do.
And one of those smoothing techniques is called LaPlace Estimation.
Now, on the other side, naïf base is also known as a bad estimate, so the probability outputs from
predict proba are not to be taken too seriously.
Another limitation of naives is the assumption of independent predictors, so in real life, it's almost
impossible that we get a set of predictors which are completely independent, you know what I mean?
All right, so.
I think that that's enough about 90 days and hopefully is pretty clear for you.
Now, let's move on to our last supervised algorithm, SVM.
So machine learning support vector machines are supervised learning models with associated learning
algorithms, and these will analyze data use for classification and regression analysis.
I given a set of training samples, each marked as belonging to either category or the other, and SVM
training algorithm creates a model that assigns new samples to one category or the other, turning it
into a non probabilistic binary linear classifier.
So in addition to performing linear classification as VMS can efficiently perform nonlinear classification
using what's called kernel numbers and implicitly map their entries to high dimensional feature fields.
When data are not labeled supervised, learning is not possible in an unsupervised learning approach
that tries to aggregate data into groups and then match them with new data is required.
The clustering algorithm that provides an enhancement to support vector machines is called support vector
clustering, and it's used for industry applications either when data is unmarked or only when some
data is tagged as a preprocessing for classification.
The SVM, or support vector machine, is a controlled machine learning algorithm that can be used for
classification or regression problems.
However, it's mostly used for classification problems.
In this algorithm, each data item is plotted as a point into the end dimensional space where N is a
number of properties you have, along with the value of each property, that is the value of a particular
coordinate.
Classification is then performed by finding the hyper plane that distinguishes quite well between the
two classes.
All right, so that sounds really interesting, how does that work?
Well.
There are two different classes in the table, blacks and whites, so our main purpose here in and in
general with all classification problems, it's to decide in which class the future data will be included.
So in order to make this classification, a line, separating the two classes is drawn and the green
region between plus or minus one of this line.
This is called margin.
So the wider the margin, the better the two or more classes can be separated.
Let's have a look at the formula.
Here w wait, Victor.
X input vector.
B is the deviation.
So if the result for a new value is less than zero, it'll be closer to the white dot.
Conversely, if the result is greater than or equal to zero, then it will be closer to the black dot.
Now, naturally, our margin might not always be this way.
Sometimes our samples can enter the margin area that's referred to as a soft margin.
A hard margin works if hard data can be separated linearly and is very sensitive to outliers.
Therefore, in some cases, we may need to actually choose soft margin.
So we can check the balance between the two with this see hyper parameter and SVM.
A larger see is the narrower the margin is also if the model is over fitted, we need to reduce see.
I remember the colonel trick I told you about earlier.
Low dimensions may not be sufficient to explain complex data sets, so if we increase the size, the
process will take too long because it will increase.
This is where that kernel trick comes in.
By multiplying the coordinates we have with certain kernel functions, we can make it much more meaningful.
Of course, you've got different methods for this, so let's have a look at the two most used methods.
There's the polynomial, Colonel.
And the Gaussian RBF, colonel.
So first, let's have a look at the polynomial, Colonel.
So in this method will act as if we are out of two dimensions and processing in three or more dimensions
in order to solve our problem.
We cannot classify the left two dimensions distribution with a straight line, so if this we can use
the polynomial kernel for such problems.
When we operate in the third dimension, we use a plane instead of a line to classify it.
And we can classify it much more properly.
If our model is overfit, we need to reduce this degree, if it's under fit, we need to increase its
degree.
Also, with coefficient zero hyper parameter, we can set how much your model will be affected by higher
order equations and it's only effective in poly and sigmoid Col's.
Now, I know you're thinking, what about the other one?
Yeah, the Gosden RBF Col well.
This will find infinite size support vector machines.
And it'll calculate how similar each point is to a certain point with normal distribution and classifies
it according.
We checked the width of the distribution with the gamma hyper parameter, the smaller the gamma, the
wider the distribution.
As in the sea hyper parameter, we need to decrease the gamma value if the model is overfit it and increase
a gamma value if the model is under.
RB F Col is generally preferred if our data set is not too large.
So what about the pros and cons?
Let's have a look.
Let's see the pros first, SVM works relatively well, and there is a clear margin of separation between
classes.
SBM is more effective in high dimensional spaces.
SVM is effective in cases where the number of dimensions is greater than the number of samples.
SVM is relatively memory efficient.
And of course, there are a few kinds.
SVM algorithms are not suitable for large datasets.
SBM does not perform very well when the data set has more noise, in other words, target classes overlapping.
Now, in cases where the number of features for each data point exceeds the number of training data
samples, yeah, the SVM will underperform.
Now, as the support vector classifier works by putting data points above and below the classifying
hydroplane, there's no probabilistic explanation for the classification.
All right, so that's it to recap this lesson, we talked about the naïf base and the SVM in supervised
learning.
And get this, my friends, that means that with this we have finished the supervised machine learning
methods.
So the next lesson, we're going to start to examine the unsupervised machine learning methods.
And until then, have a great day.