<jupyter_start><jupyter_text>Using Iris data to looking at some some Machine Learning algorithms<jupyter_code>from sklearn.datasets import load_iris
iris= load_iris()
type(iris)
print iris.data
print iris.feature_names
print iris.target
print iris.target_names
print type(iris.data)
print type(iris.target)
print iris.data.shape
print iris.target.shape
x=iris.data

y=iris.target
x
y
print x.shape
print y.shape<jupyter_output>(150L, 4L)
(150L,)<jupyter_text>K-Nearest Neighbors<jupyter_code>from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=1) # instantiate the estimator
knn # implicitly, it fills in a lot of implicit information.
knn.fit(x, y)
knn.predict([3, 5, 4, 2])
x_new = [[3, 5, 4, 2], [5, 4, 3, 2]]
knn.predict(x_new)<jupyter_output><empty_output><jupyter_text>Note that we have no way of knowing the target for x_new. This motivates the need to divide up the dataset into training, and testing dataset  Logistic Regression<jupyter_code>from sklearn.linear_model import LogisticRegression
logreg=LogisticRegression()  #instantiating 
logreg.fit(x, y)  # fitting the logistic model with the complete dataset
logreg.predict(x_new)<jupyter_output><empty_output><jupyter_text>Split the dataset into training, and testing sets<jupyter_code>from sklearn.cross_validation import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.4)   
#test_size=.4 means it should let 40% of the dataset be part of the testing set
print x_train.shape
print y_train.shape
print x_test.shape
print y_test.shape<jupyter_output>(60L, 4L)
(60L,)
{'fraction_non_alphanumeric': 0.08841843088418432, 'fraction_numerical': 0.0186799501867995, 'mean_word_length': 6.688995215311005, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '488374', 'license': 'Unlicense', 'n_tokens_mistral': 611, 'n_tokens_neox': 575, 'n_words': 163, 'path': 'Sklearn/Machine Learning using Scikit-Learn.ipynb', 'repo_name': 'PhillipWongSeven/Machine-Learning-Simplified', 'size': '1606'}