-
Notifications
You must be signed in to change notification settings - Fork 0
/
sparse_gp_wtdata_czc_nkmeans.py
56 lines (42 loc) · 1.45 KB
/
sparse_gp_wtdata_czc_nkmeans.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python
# Standard libraries
import time
import numpy as np
import warnings
import csv
from sparse_gp_wtdata import *
warnings.filterwarnings("ignore")
def save_czc_nkmeans_results(results):
if results:
fields = results[0].keys()
with open(f"sgp_wtdata_results_czc_nkmeans.csv", "w", newline="") as file:
writer = csv.DictWriter(file, delimiter=",", fieldnames=fields)
writer.writeheader()
writer.writerows(results)
if __name__ == "__main__":
start = time.time()
print("Loading data...")
df = load_database()
X = np.array(df[INPUT_NAMES])
print("Data loaded in {:.2f}s".format(time.time() - start))
# Set seed
np.random.seed(0)
print("Computing...")
start = time.time()
results = []
inducing_method = "NORM_KMEANS"
output_name = "CZC"
Y = np.array(df[[output_name]])
for M in [50, 100, 200, 500, 1000]:
for sparse_method in SPARSE_METHODS:
print(
f"*** {output_name} - {sparse_method} - {inducing_method} - M={M} ******************"
)
res = sgp_compute(X, Y, output_name, sparse_method, inducing_method, M)
print(res)
results.append(res)
# save intermediate results
save_czc_nkmeans_results(results)
elapsed = time.time() - start
print("Computation in {:.2f}s".format(time.time() - start))
save_czc_nkmeans_results(results)