Last active
August 1, 2020 16:41
-
-
Save shayaf84/cff6602ae018dbc96803d6d2eec96cee to your computer and use it in GitHub Desktop.
KNN, and Logistic Regression
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
### Here we load the train and test data for you to use. | |
(train_data, train_labels) = get_train_data(flatten = True) | |
(test_data, test_labels) = get_test_data(flatten = True) | |
############ | |
knn = KNeighborsClassifier(n_neighbors=10) | |
log_reg = LogisticRegression() | |
knn.fit(train_data, train_labels) | |
log_reg.fit(train_data, train_labels) | |
predictions = knn.predict(test_data) | |
score = accuracy_score(test_labels, predictions) | |
print("KNN accuracy:",score) | |
predictions = log_reg.predict(test_data) | |
score = accuracy_score(test_labels, predictions) | |
print("Logistic Regression accuracy:",score) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment