-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from lannerate/master
add kNNTest
- Loading branch information
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |