# import load_iris function from datasets module 
from sklearn.datasets import load_iris

iris = load_iris()
X = iris.data
y = iris.target
print X.shape
print y.shape

"""
Explanation: https://www.youtube.com/watch?v=RlQuVL6-qe8&index=4&list=PL5-da3qGB5ICeMbQuqbbCOQWcS6OYBr5A
Reviewing the iris dataset
K-nearest neighbors (KNN) classification

Pick a value for K 
Search for K observations in the training data that are "nearest" to the measurements of the unknown Iris. 
use the most popular response value from the K nearest neighbors as the predicted response value for the unknown Iris.
End of explanation
"""


from sklearn.neighbors import KNeighborsClassifier 

"""
Explanation: skikit-learn 4-step modeling pattern

Step1: import the class you plan to use
End of explanation
"""


knn = KNeighborsClassifier(n_neighbors=1)

"""
Explanation: Step 2: "Instantiate" the "estimator"
"Estimator" is scikit-learn's term for model 
"Instantiate" means "makes an instance of"
End of explanation
"""


print knn

"""
Explanation: + Name of the object does not matter
+ Can specify tuning parameters during this step
+ All parameters not specified are set to defaults.
End of explanation
"""


knn.fit(X,y)

"""
Explanation: Step 3: Fit the model with data ("model training")
Model is learning the relationship between X and y
Occurs in-place
End of explanation
"""


knn.predict([3,5,4,2])

X_new = [[3,5,4,2], [5,4,3,2]]
knn.predict(X_new)


"""
Explanation: Step 4: predict the response for a new observation
New observations are called "out-of-sample" data 
Uses the information it learned during the model training shape
End of explanation
"""


knn = KNeighborsClassifier(n_neighbors=5)

knn.fit(X,y)
knn.predict(X_new)

"""
Explanation: Using a different value for K
End of explanation
"""


from sklearn.linear_model import LogisticRegression

logreg = LogisticRegression()

logreg.fit(X,y)

logreg.predict(X_new)

"""
Explanation: Using a different classification model
End of explanation
"""


