Hi. In this video we will create a multi classification model.
With live G B M.
We'll use the same data set as for clustering, uh, the 21 types of attacks.
Uh, this data set has 500 K observations and 42 columns.
We have already prepared it, uh, so we can split, uh,
the data into train and test set with, uh,
30% to be the test data.
We also specify here the random state parameter,
which basically specifies the random seed number during sampling.
When we call these methods, trying to split with the same number again,
we'll get the same sample.
We have also specified here the stratify parameter
because we want cut.
We have also specified the stratify parameter because we want that, uh,
both trained and test set will cover all 21 types of attacks.
If we would not, uh, cut,
if we would not stratify our sample on the target,
it may happen that in the train set,
we will not have the same classes as in the test set.
Now let's create our live G B A model.
We will use a default parameter except these two.
We have to specify our objective.
We are trying to solve a multi classification problem,
and we know that our data set is highly imbalanced,
where most of the observations are smurf or Neptune attack
and normal connections. Uh,
so we have to specify balanced to class weight parameter.
Uh,
this way the I G B M knows we want that all target classes must
be treated equally important. You could set, uh,
here the weights for each attack. That way that the most critical attacks,
uh,
with the most damage would have much higher weight than other type of attacks or
the normal connections. Uh, these, uh,
three classes, which I mentioned make, uh, 96% of the dataset.
In case of, uh, other algorithm, which, uh,
does not support this parameter, you would've to manually balance the dataset,
for example, using the imbalanced learn library.
Now let's fit and evaluate the model.
Don't worry about this output.
We see a very nice performance of 99.9%,
but we have to evaluate it closer using classification report and, uh,
the confusion metrics.
We see that in the most frequent classes,
it has an excellent performance.
And also on the less frequent classes in the rarest classes, it struggles a bit,
uh, but it is not so bad as well. But also it is harder to evaluate, uh,
because they are so rare.
Here we can also export the confusion metrics.
I made it this way because the confusion matrix display in stickler did not
properly visualize the metrics with, uh, more target classes. And
we see, for example here that, uh,
the model misclassified, uh, both, uh, F T P right attacks,
uh, with the P H F attacks
regarding model persistence.
We can use job leap or pickle Library to save and load the train model to this.
And
also we predict proba and predict we can get the predictions and predicted
probabilities.
The probabilities for all classes in one observations always sums to one.
Okay, that was it for this module.
I hope it was interesting and that we have learned something new.
Let's summarize it.
We went through a lot of things we have learned about the Cains clustering
algorithm.
We trained a model and evaluated the quality of clustering with geo metrics
in order to find proper number of clusters.
We have learned the basics about the XG boost algorithm,
and we have created a binary model to predict if an email is a spam or
not. We have learned the basics of a live G B M algorithm,
and we created a multi classification model to classify connections to various
attack types.
We have learned also how to best evaluate the model using cross validation
technique. We also learned about, uh, seeking learns,
transformers, estimators, and how to organize them into a pipeline.
And we also learned how to search for the best hyper parameters of the model and
pipeline using grid search,
randomized search and tune search with a more advanced optimizer.
Next, we'll start our new module focused on Jupiter Hub.