Last active
May 19, 2016 17:47
-
-
Save matmoody/ec83a619155e442e752f778866f6f5e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
iris = pd.read_csv("https://raw.githubusercontent.com/Thinkful-Ed/curric-data-001-data-sets/master/iris/iris.data.csv", names = ['Sepal_l', 'Sepal_w', 'petal_l', 'petal_w', 'class']) | |
# Plot iris data | |
plt.scatter(iris['Sepal_l'], iris['Sepal_w']) | |
plt.xlabel('Sepal length') | |
plt.ylabel('Sepal Width') | |
plt.show() | |
X = iris[['Sepal_l', 'Sepal_w']] | |
X_random = X.ix[17] | |
from sklearn.neighbors import NearestNeighbors | |
# Identify the 10 nearest neighbors | |
nbrs = NearestNeighbors(n_neighbors=10, algorithm='ball_tree').fit(X) | |
distances, indices = nbrs.kneighbors(X) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment