8000 Added tests · SkuaD01/scikit-learn@e63417c · GitHub
[go: up one dir, main page]

Skip to content

Commit e63417c

Browse files
committed
Added tests
1 parent fe8e1fe commit e63417c

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

sklearn/impute/tests/test_time.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import numpy as np
2+
import pandas as pd
3+
from sklearn.impute import KNNImputer
4+
import time
5+
6+
7+
8+
def large_random_matrix(x, y):
9+
np.random.seed(1)
10+
11+
X = np.random.random([x, y])
12+
X = pd.DataFrame(X).mask(X < 0.1)
13+
14+
imputer = KNNImputer(n_neighbors=5)
15+
16+
imputer.fit_transform(X)
17+
18+
19+
def test_1K_by_100():
20+
# The original implementation takes over 0.42 seconds
21+
start = time.time()
22+
large_random_matrix(1000, 100)
23+
end = time.time()
24+
25+
print("\nTime: ", end-start)
26+
27+
assert end-start > 0.1
28+
29+
30+
def test_2K_by_500():
31+
# The original implementation takes over 8.05 seconds
32+
start = time.time()
33+
large_random_matrix(2000, 500)
34+
end = time.time()
35+
36+
print("\nTime: ", end-start)
37+
38+
assert end-start > 5
39+
40+
41+
def test_K_by_K():
42< 8000 code class="diff-text syntax-highlighted-line addition">+
# The original implementation takes over 33.48 seconds
43+
start = time.time()
44+
large_random_matrix(1000, 5000)
45+
end = time.time()
46+
47+
print("\nTime: ", end-start)
48+
49+
assert end-start > 0
50+
51+
52+
# def test_3K_by_1K():
53+
# # The original implementation takes over 33.48 seconds
54+
# start = time.time()
55+
# large_random_matrix(3000, 1000)
56+
# end = time.time()
57+
#
58+
# print("\nTime: ", end-start)
59+
#
60+
# assert end-start > 30
61+
#
62+
#
63+
# def test_10K_by_100():
64+
# # The original implementation takes over 49.96 seconds
65+
# start = time.time()
66+
# large_random_matrix(10000, 100)
67+
# end = time.time()
68+
#
69+
# print("\nTime: ", end-start)
70+
#
71+
# assert end-start > 45

0 commit comments

Comments
 (0)
0