Skip to content
Snippets Groups Projects
Commit 30ace205 authored by widad174's avatar widad174
Browse files

Update

parent f95233fe
Branches
No related tags found
No related merge requests found
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -2,6 +2,10 @@ from knn import * ...@@ -2,6 +2,10 @@ from knn import *
import numpy as np import numpy as np
def test_distance_matrix(): def test_distance_matrix():
'''
Check that's if the function distance_matrix
returns the good shape of the output dists.
'''
train = np.random.rand(100, 1000) train = np.random.rand(100, 1000)
test = np.random.rand(80, 1000) test = np.random.rand(80, 1000)
dists = distance_matrix(train, test) dists = distance_matrix(train, test)
......
from knn import * from knn import *
import numpy as np import numpy as np
...@@ -6,5 +7,11 @@ def test_evaluate_knn(): ...@@ -6,5 +7,11 @@ def test_evaluate_knn():
test = np.random.rand(80, 1000) test = np.random.rand(80, 1000)
labels_train = np.random.randint(10, size=100) labels_train = np.random.randint(10, size=100)
labels_test = np.random.randint(10, size=80) labels_test = np.random.randint(10, size=80)
accuracy = evaluate_knn_for_k(train, labels_train, test, labels_test, k=3) accuracy = evaluate_knn_for_k(train, labels_train, test, labels_test, 3)
assert isinstance(accuracy, float)
\ No newline at end of file print("Type of accuracy:", type(accuracy))
print("Accuracy:", accuracy)
assert isinstance(accuracy, list)
test_evaluate_knn()
...@@ -9,4 +9,3 @@ def test_knn_predict(): ...@@ -9,4 +9,3 @@ def test_knn_predict():
labels_pred = knn_predict(dists, labels_train, k=3) labels_pred = knn_predict(dists, labels_train, k=3)
assert labels_pred.shape == (80,) assert labels_pred.shape == (80,)
print(test_knn_predict())
\ No newline at end of file
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment