Warning: Declaration of action_plugin_tablewidth::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /s/bach/b/class/cs545/public_html/fall16/lib/plugins/tablewidth/action.php on line 93
"""
Nearest neighbor classification with scikit-learn
full details at:
http://scikit-learn.org/stable/modules/neighbors.html#classification
"""
import numpy as np
from sklearn import neighbors, datasets
import decision_boundary
# import some data to play with
iris = datasets.load_iris()
X = iris.data[:, :2] # take the first two features.
y = iris.target
# the parameters of the scikit-learn nearest neighbor
# classifier:
# sklearn.neighbors.KNeighborsClassifier(n_neighbors=5,
# weights='uniform', algorithm='auto', leaf_size=30, p=2,
# metric='minkowski')
# weights refers to how to weight each example
# 'algorithm' is the choice of algorithm for storing the
# training data ('brute', 'ball_tree', 'kd-tree')
# complete description of the available metrics:
# http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.DistanceMetric.html#sklearn.neighbors.DistanceMetric
classifier = neighbors.KNeighborsClassifier(n_neighbors=10)
decision_boundary.plot_boundary(classifier, X, y)