-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample4.py
52 lines (36 loc) · 1.2 KB
/
example4.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
# tuneParams: algorithm parameters tuning
import pandas as pd
from algormeter import *
import algormeter.algorithms as alg
alpha = 1.
beta = 1.
def gradient(p, **kwargs):
for k in p.loop():
p.Xkp1 = p.Xk - alpha/(k+1) * p.gfXk / np.linalg.norm(p.gfXk) # type: ignore
# print (alpha,beta)
tpar : TuneParameters = [ # [name, [values list]]
('alpha', [1. + i for i in np.arange(.05,.9,.05)]),
('beta', [1., 2., 3.]),
]
problems : Problems = [
(Parab,[2,4,6]),
(ParAbs,[2]),
(Acad,[2]),
]
algorithms : Algorithms = [
gradient,
]
dff, pv = algorMeter(algorithms = algorithms, problems = problems, iterations = 3000,
tuneParameters=tpar,
)
print('\n', dff)
print('\n', pv)
df = dff[dff.Status == 'Success']
# df = df[ df.TuneParams.str.contains("alpha': 0.3") ]
df = df.groupby(['TuneParams','Status',]).agg({'Status':'count','f1':'sum'})
df.rename(columns={'Status': 'count'}, inplace=True)
df = df.sort_values(['count','f1'],ascending=[False, True])
pd.options.display.max_rows = 2000
pd.options.display.max_colwidth = 1000
print(df)
# or better to use spreadsheet pivot from csv