-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.py
More file actions
26 lines (19 loc) · 778 Bytes
/
Copy pathexample.py
File metadata and controls
26 lines (19 loc) · 778 Bytes
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
#example of using the BIAS toolbox to test a DE algorithm
from scipy.optimize import differential_evolution
import numpy as np
from BIAS import BIAS, f0, install_r_packages
install_r_packages()
bounds = [(0,1), (0, 1), (0, 1), (0, 1), (0, 1)]
#do 30 independent runs (5 dimensions)
samples = []
print("Performing optimization method 50 times of f0.")
for i in np.arange(50):
result = differential_evolution(f0, bounds, maxiter=100)
samples.append(result.x)
samples = np.array(samples)
test = BIAS()
# use the classical stastistical approach to detect BIAS
print(test.predict(samples, show_figure=True))
#use the trained deep learning model to predict and explain BIAS
y, preds = test.predict_deep(samples)
test.explain(samples, preds, filename="explanation.png")