Hello everyone, welcome to the course of machine learning with Python. In this video, we shall learn how to implement knee based classification. In Python, we shall use wind data set which is available under the library escalon dot data sets. So first we'll be importing the necessary libraries. So from SK learn dot datasets input load underscore wine and import NumPy as NP. So let's go ahead and run this particular cell.
Now we'll be loading the data set. So y is equals to load underscore wine. So inside this wine variable, the data of the wind data set will be loaded. So now we'll be exploring the data. So what are the features so wind dot feature underscore names will contain the name of all the features. So there are alcohol malic acid, H, alkalinity of H, magnesium etc.
And wind dot target underscore names. We continue Target names or the labels. Similarly, we can print the description of the entire data set just by using this command print within bracket wine dot d s er so DCR stands for described. So there are total 178 instances 50 in each of the three classes, number of attributes 30 numeric predictive attributes and the class activity information alcohol, malic acid H, alkalinity of H magnesia, total phenols, etc. And there are total three classes class to class one and class two. It also prints the summary statistics, so there are no missing attributes.
Okay, and the original data set archive is also given over here. Now, we'll be loading the feature set x and the target variable y. So x is equals to wine dot data and y equals to wine dot target. So What is the shape of this feature set? It is 178 comma 13 because it contains 178 instances or samples and each sample is a vector of dimension 13 that means, it contains 13 features. Now splitting the data set into training and paste here we shall use 75% training and 25% is data.
So, from SK learn dot model underscore selection will be importing crane underscore test underscore split. So, using this function we can split the data set into train and test. So, x train will contain the feature set of the training x test will contain the feature set of the test y train will contain the label of the training data set and y test will contain the label of the test data set. And I have specified test sizes because 2.25 so that 25% are being used as tested data So let's go ahead and run this particular cell. So what is the shape of the screen? So it is 133 comma 13.
So out of 178 instances 133 instances has been picked randomly as the training sample and rest risk 45 instances has been used for test. Now we'll be creating the model. So from SK learn dot name underscore Bayes will import Gaussian envy. So Gaussian envy stands for Gaussian Naive Bayes model. So this is basically a class GNP is a object of the class Gaussian in V. So we run these cells and in this object, we'll be fitting our x train and y train. Okay.
So after that, we'll be testing or predicting By the model. So for this we'll be using GNP dot predict we thought, and we have supplied the entire test data set, and we'll be receiving the predicted values or the predicted classes. Now we'll be evaluating the model performance. So from SK learn dot matrix, we'll be importing confusion matrix. So cm is our confusion matrix, which takes two argument whitest and white credit. Let's see what is our confusion matrix.
So, this is how our confusion matrix looks like. So corrects will be NP dot Chris within bracket cm. So that means all the data some of the diagonal elements are put on repeat the some of the all elements of the confusion matrix. So total number of correct prediction sorry, out of this mini prediction, so total number of correct prediction is 42 out of 45. So what will be the accuracy so the accuracy of the model is 93.33%. Sent which is quite high.
Now from SK learn dot matrix we'll be importing classification report and we'll be printing the classification report which is a function which takes two argument whitest and by credit. So this will be printing the precision recall an X score of all the classes. So I hope you have enjoyed this video. In the next video we shall discuss about decision tree classification. So see you in the next lecture. Thank you