Skip to content

Commit

Permalink
tiny typos were fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
a-pertsev committed Mar 5, 2019
1 parent f8f1211 commit f7dc767
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions assignments/assignment1/knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


class KNN:
"""
K-neariest-neighbor classifier using L1 loss
"""
'''
K-nearest-neighbor classifier using L1 loss
'''
def __init__(self, k=1):
self.k = k

Expand All @@ -14,8 +14,8 @@ def fit(self, X, y):

def predict(self, X, num_loops=0):
'''
Uses the KNN model to predict clases for the data samples provided
Uses the KNN model to predict classes for the data samples provided
Arguments:
X, np array (num_samples, num_features) - samples to run
through the model
Expand Down Expand Up @@ -44,7 +44,7 @@ def compute_distances_two_loops(self, X):
Arguments:
X, np array (num_test_samples, num_features) - samples to run
Returns:
dists, np array (num_test_samples, num_train_samples) - array
with distances between each test and each train sample
Expand All @@ -64,7 +64,7 @@ def compute_distances_one_loop(self, X):
Arguments:
X, np array (num_test_samples, num_features) - samples to run
Returns:
dists, np array (num_test_samples, num_train_samples) - array
with distances between each test and each train sample
Expand All @@ -84,7 +84,7 @@ def compute_distances_no_loops(self, X):
Arguments:
X, np array (num_test_samples, num_features) - samples to run
Returns:
dists, np array (num_test_samples, num_train_samples) - array
with distances between each test and each train sample
Expand All @@ -99,13 +99,13 @@ def compute_distances_no_loops(self, X):
def predict_labels_binary(self, dists):
'''
Returns model predictions for binary classification case
Arguments:
dists, np array (num_test_samples, num_train_samples) - array
with distances between each test and each train sample
Returns:
pred, np array of bool (num_test_samples) - binary predictions
pred, np array of bool (num_test_samples) - binary predictions
for every test sample
'''
num_test = dists.shape[0]
Expand All @@ -119,17 +119,16 @@ def predict_labels_binary(self, dists):
def predict_labels_multiclass(self, dists):
'''
Returns model predictions for multi-class classification case
Arguments:
dists, np array (num_test_samples, num_train_samples) - array
with distances between each test and each train sample
Returns:
pred, np array of int (num_test_samples) - predicted class index
pred, np array of int (num_test_samples) - predicted class index
for every test sample
'''
num_test = dists.shape[0]
num_test = dists.shape[0]
pred = np.zeros(num_test, np.int)
for i in range(num_test):
# TODO: Implement choosing best class based on k
Expand Down

0 comments on commit f7dc767

Please sign in to comment.