-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperformance.py
43 lines (33 loc) · 1.26 KB
/
performance.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
import yaml
import matplotlib.pyplot as plt
# rename
def calculate_performance():
# Load data from YAML file
yml_path = "./performance.yml"
with open(yml_path, "r") as file:
performances = yaml.safe_load(file)
# Extract data for each metric
f1_data = performances['f1']
mae_data = performances['mae']
# Sort metrics based on scores
sorted_f1_data = sorted(f1_data.items(), key=lambda x: x[1])
sorted_mae_data = sorted(mae_data.items(), key=lambda x: x[1], reverse=True)
# Extract sorted keys and values
f1_keys = [item[0] for item in sorted_f1_data]
f1_values = [item[1] for item in sorted_f1_data]
mae_keys = [item[0] for item in sorted_mae_data]
mae_values = [item[1] for item in sorted_mae_data]
# Plotting
fig, axs = plt.subplots(1, 2, figsize=(12, 6))
# Subplot 1 for F1 metrics
axs[0].barh(f1_keys, f1_values, color='skyblue')
axs[0].set_xlabel('F1 Scores')
axs[0].set_title('F1 Metrics')
axs[0].grid(True) # Add grid lines
# Subplot 2 for MAE metrics
axs[1].barh(mae_keys, mae_values, color='salmon')
axs[1].set_xlabel('MAE Scores')
axs[1].set_title('MAE Metrics')
axs[1].grid(True) # Add grid lines
plt.tight_layout()
plt.savefig("performance.pdf")