Skip to content

Commit

Permalink
Merge pull request #12 from lannerate/master
Browse files Browse the repository at this point in the history
add kNNTest
  • Loading branch information
pbharrin authored Dec 25, 2017
2 parents 61141e4 + ca7c282 commit c1ea22f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Ch02/EXTRAS/createFirstPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
@author: Peter
'''
from numpy import *
import kNN
import matplotlib
import matplotlib.pyplot as plt
from Ch02 import kNN

fig = plt.figure()
ax = fig.add_subplot(111)
datingDataMat,datingLabels = kNN.file2matrix('datingTestSet.txt')
datingDataMat,datingLabels = kNN.file2matrix('../datingTestSet.txt')
#ax.scatter(datingDataMat[:,1], datingDataMat[:,2])
ax.scatter(datingDataMat[:,1], datingDataMat[:,2], 15.0*array(datingLabels), 15.0*array(datingLabels))
ax.axis([-2,25,-0.2,2.0])
Expand Down
23 changes: 23 additions & 0 deletions Ch02/kNNTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'''
Created on Oct 27, 2010
@author: Peter
'''
from numpy import *
import matplotlib
import matplotlib.pyplot as plt

from Ch02 import kNN

fig = plt.figure()
ax = fig.add_subplot(111)
datingDataMat,datingLabels = kNN.file2matrix('datingTestSet.txt')
# ax.scatter(datingDataMat[:,1], datingDataMat[:,2])
ax.scatter(datingDataMat[:,1], datingDataMat[:,2], 15.0*array(datingLabels), 15.0*array(datingLabels))
ax.axis([-2,25,-0.2,2.0])
plt.xlabel('Percentage of Time Spent Playing Video Games')
plt.ylabel('Liters of Ice Cream Consumed Per Week')
plt.show()

#Test dating class
# kNN.datingClassTest()

0 comments on commit c1ea22f

Please sign in to comment.