May 2018
Beginner
490 pages
13h 16m
English
The program imports the V1.csv file described before, prints a few lines, and prepares the labels in the right arrays in their respective x axis and y axis, as shown in this source code example.
import pandas as pdfrom matplotlib import pyplot as pltfrom sklearn.neighbors import KNeighborsClassifier# Import datadf = pd.read_csv('V1.csv')print (df.head())# Classification labelsX = df.loc[:,'broke':'shouted']Y = df.loc[:,'class']
Then the model is trained as shown in the following code:
# Trains the modelknn = KNeighborsClassifier()knn.fit(X,Y)
Once the model is trained, a prediction is requested and is provided by the following code.
# Requesting a prediction#broke and stopped are#activated to see the best choice ...
Read now
Unlock full access