Skip to main content

Here we will use the standard scalar class

The following code imports required libraries:

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

%matplotlib inline

14- Importing the Dataset

Execute the following command to import the dataset.

banknote_data = pd.read_csv(rD:\Datasets\banknote_data.csv)

The script above reads the dataset and stores it in banknote_data dataframe.

15- Analyzing the Data

The following script returns the data dimensions:


The above script returns (1372, 5) which means that our dataset contains 1372 records and five attributes.

Execute the following script to eyeball the data:


The output looks like this:

16- Data Preprocessing

To following script divides the data into feature and label set.

features= banknote_data.iloc[:,0:4].values

labels= banknote_data.iloc[:,4].values

Finally let’s divide the data into 80 % training and 20% test sets:

from sklearn.model_selection import train_test_split

train_features, test_features, train_labels, test_labels = train_test_split(features, labels, test_size = 0.2, random_state = 0)

17- Scaling the Data

If you are using KNN algorithm , it is always a good practice to scale your data. Remember we discussed scaling in the 3rd chapter. Here we will use the standard scalar class.

from sklearn.preprocessing import StandardScaler

feature_scaler = StandardScaler()

train_features = feature_scaler.fit_transform(train_features)

test_features = feature_scaler.transform(test_features)

18- Training the Algorithm and making Predictions

To implement KNN Algorithm with Scikit learn we need to use the KNeighborsClassifier class of the sklear.neighbors library. The value of K is specified as value for the n_neighbors parameter as shown in the following script. We use a value of 3 for K. Execute the following script to train the model on train_features and train_labels

Popular posts from this blog

How to make your coke high go away

Right this moment I only eat natural meals and truthful commerce whenever I can, in my youth nonetheless I took drugs filled with poisonous chemical substances and contaminated with the environmental harm and the brutality of the illegal drug trade. I actually admire all the recommendation that i've gotten.I guess by being so naive about drugs has been my set back.I came from the mid fiftys the place the drug scence was not as it's i remember being young and everybody using pot lsd higher's downer's what ever.I actually do not need a pill addiction,so i can not really say how it i know one factor that this oxy or what ever methodology you select can only drive you insane dead or locked up.I simply wish there was some kind of a quick treatment to finish the misery individuals go all of your recommendation is far appreciated,good luck to all these brave enough to make a stand and give up the know who make's all of the profit the supplier and the Dr.'s prescribing…

how to install wow addons windows 10

How To Install Wow Addons MacCurse Consumer is an addon management software for games corresponding to World of Warcraft and others, which sadly doesn't work on Linux. The "AddOns" button ought to seem within the lower left nook of the WoW window. Sometimes, though, Blizzard really adjustments one thing that breaks a few of your AddOns. When this happens, you'll know as a result of the AddOn will generate an error message or in any other case not work, regardless that you've got obtained "Load out of date AddOns" checked, and all you can do is check online to see if the AddOn in question has been updated but. Thankfully, AddOn authors are typically pretty quick to update, particularly if it's a popular AddOn.

Wow Addons Not Showing UpAchtung: Wenn Sie Programmbibliotheken von Addos haben, die sich selbst installieren und das Addon-Verzeichnis reinigen, oder Werkzeuge wie Curse Client, ist es besser, Auctioneer zuerst in ein anderes Verzeichnis zu ins…

how to make my wish come true tonight

Observe your dreams, because desires do come true. I want tonight when I go to sleep that I will get up the morning of July 25,2013 in my outdated room at my old house in Virginia Seaside and have my household resolve to not transfer to Minnesota but to remain living in Virginia Seaside, VA and that myself and my brother Nick, my sister Amanda, and my buddies Kayleesue, Miriam, and Kayla Rain, my nice aunt Shirl and great uncle Bobby to have reminiscence of me really transferring to Minnesota. Additionally that we get back the furniture that we gave to my sister Amanda and that my Mom gets again her job at Animal Management.

How To Make A Wish Come True No Joke

I wish to have discovered love in the kind of what is known as a furry: Her title is Victoria, she is ninety pounds, she has an IQ of 467, she is admittedly candy to people, she has probably the most lovely gray waterproof fur coat, she carries a common translator with her that can educate people any language conceivable by the h…