-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from fzi-forschungszentrum-informatik/COMTE
Comte
- Loading branch information
Showing
19 changed files
with
604 additions
and
12,456 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+1.38 KB
(110%)
ClassificationModels/models/ECG5000/ResNet_confusion_matrix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions
8
ClassificationModels/models/ECG5000/classification_report.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0,1,2,3,4,accuracy,macro avg,weighted avg | ||
0.9821088694328131,0.9282567652611705,0.6521739130434783,0.32051282051282054,0.5,0.9248888888888889,0.6766104736500564,0.928689990417054 | ||
0.9821088694328131,0.9276729559748428,0.3488372093023256,0.42857142857142855,0.09090909090909091,0.9248888888888889,0.5556199108381001,0.9248888888888889 | ||
0.9821088694328131,0.9279647687952186,0.4545454545454546,0.36674816625916873,0.15384615384615385,0.9248888888888889,0.5770426825757616,0.9249156524345059 | ||
2627.0,1590.0,86.0,175.0,22.0,0.9248888888888889,4500.0,4500.0 | ||
0.967861100849649,0.9443671766342142,0.6530612244897959,0.2962962962962963,0.5555555555555556,0.9117777777777778,0.6834282707651023,0.9254116138134725 | ||
0.9973353635325466,0.8540880503144654,0.37209302325581395,0.5028571428571429,0.22727272727272727,0.9117777777777778,0.5907292614465391,0.9117777777777778 | ||
0.9823772028496438,0.8969616908850727,0.47407407407407404,0.37288135593220334,0.3225806451612903,0.9117777777777778,0.6097749937804569,0.9155545293878521 | ||
2627.0,1590.0,86.0,175.0,22.0,0.9117777777777778,4500.0,4500.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
TSInterpret/InterpretabilityModels/counterfactual/COMTE/Optimization_helpers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import numpy as np | ||
|
||
|
||
def random_hill_climb( | ||
problem, | ||
max_attempts=10, | ||
max_iters=np.inf, | ||
restarts=0, | ||
init_state=None, | ||
curve=False, | ||
random_state=None, | ||
): | ||
# Set random seed | ||
if isinstance(random_state, int) and random_state > 0: | ||
np.random.seed(random_state) | ||
|
||
best_fitness = np.inf | ||
best_state = None | ||
|
||
if curve: | ||
fitness_values = [] | ||
|
||
for _ in range(restarts + 1): | ||
# Initialize optimization problem and attempts counter | ||
if init_state is None: | ||
problem.reset() | ||
else: | ||
problem.set_state(init_state) | ||
|
||
attempts = 0 | ||
iters = 0 | ||
|
||
while (attempts < max_attempts) and (iters < max_iters): | ||
iters += 1 | ||
|
||
# Find random neighbor and evaluate fitness | ||
next_state = problem.random_neighbor() | ||
next_fitness = problem.eval_fitness(next_state) | ||
|
||
if next_fitness < problem.get_fitness(): | ||
problem.set_state(next_state) | ||
attempts = 0 | ||
|
||
else: | ||
attempts += 1 | ||
|
||
if curve: | ||
fitness_values.append(problem.get_fitness()) | ||
|
||
# Update best state and best fitness | ||
# print('best_fitness',best_fitness) | ||
if problem.get_fitness() < best_fitness: | ||
best_fitness = problem.get_fitness() | ||
best_state = problem.get_state() | ||
# print('bestfitness after', best_fitness) | ||
|
||
if curve: | ||
import matplotlib.pyplot as plt | ||
|
||
plt.plot(np.asarray(fitness_values)) | ||
plt.show() | ||
|
||
return best_state, best_fitness |
Oops, something went wrong.