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 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…

how to lose a guy in 10 days full movie download

Watch Tips on how to Lose a Guy in 10 Days On-line - Free Streaming 2003 Full Film HD on Putlocker. Kate Hudson sells us on loads of dumb dialogue on this film, exhibiting the chutzpah she'd have to float future duds like Elevating Helen, You, Me, and Dupree, and Fools Gold. Man, Elevating Helen. That could be a Unhealthy Film We Dropkick At Terrorists. Meanwhile, McConaughey displays basic McConaugheyianism; he is a person's man who is too hammy and useless to be a real man's man. I get that he is hot, however who retains casting him as a feasible dude icon? He's Ty Pennington with motorbike hair.

Watch How To Lose A Guy In 10 Days 123moviesWatch how to lose a guy in 10 days 123movies

Where Is The Setting Of How To Lose A Guy In Ten DaysThey go their separate methods earlier than Ben is shown Andie's article and encouraged to learn it. She explains in it how she "misplaced the one individual she ever fell for", and when he hears she give up her job at Comp…