Skip to content

Commit c4a9ca8

Browse files
committed
WIP
1 parent ddb0ec5 commit c4a9ca8

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/conformist/model_vs_cop_fnr.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class ModelVsCopFNR(OutputDir):
99
FIGURE_HEIGHT = 8
1010
plt.rcParams.update({'font.size': FIGURE_FONTSIZE})
1111

12+
plt.rcParams["pdf.fonttype"] = 42 # If saving as PDF too
13+
plt.rcParams["font.family"] = "Univers, DejaVu Sans" # Choose a font that supports embedding
14+
15+
1216
def __init__(self,
1317
prediction_dataset: PredictionDataset,
1418
cop_class,
@@ -62,9 +66,10 @@ def do_round(x):
6266
'model_tprs': model_tprs}
6367

6468
def run_reports(self):
65-
plt.figure(figsize=(self.FIGURE_WIDTH,
66-
self.FIGURE_HEIGHT))
69+
fig = plt.figure()
6770
plt.tight_layout()
71+
plt.rcParams.update({'font.size': 6})
72+
6873

6974
model_rates = []
7075
model_mean = 0
@@ -98,5 +103,7 @@ def run_reports(self):
98103
plt.legend(loc='upper right')
99104

100105
# Save the plot to a file
101-
plt.savefig(f'{self.output_dir}/model_vs_CoP_FNR.png')
106+
fig.set_size_inches(4, 3)
107+
plt.tight_layout(w_pad=0)
108+
plt.savefig(f'{self.output_dir}/model_vs_CoP_FNR.pdf', format='pdf')
102109
print(f'Reports saved to {self.output_dir}')

src/conformist/validation_trial.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class ValidationTrial(OutputDir):
1313
FIGURE_HEIGHT = 8
1414
plt.rcParams.update({'font.size': FIGURE_FONTSIZE})
1515

16+
plt.rcParams["pdf.fonttype"] = 42 # If saving as PDF too
17+
plt.rcParams["font.family"] = "Univers, DejaVu Sans" # Choose a font that supports embedding
18+
19+
1620
def __init__(self,
1721
runs,
1822
class_names=[]):
@@ -149,9 +153,10 @@ def run_reports(self, base_output_dir):
149153
print(f'Reports saved to {self.output_dir}')
150154

151155
def visualize_empirical_fnr(self):
152-
plt.figure(figsize=(self.FIGURE_WIDTH,
153-
self.FIGURE_HEIGHT))
156+
fig = plt.figure()
154157
plt.tight_layout()
158+
plt.rcParams.update({'font.size': 6})
159+
155160

156161
# Generate a pastel palette
157162
color_palette = sns.color_palette("deep")
@@ -192,7 +197,10 @@ def visualize_empirical_fnr(self):
192197
transform=ax.transAxes)
193198

194199
# Save the figure
195-
plt.savefig(f'{self.output_dir}/empirical_fnr.png')
200+
fig.set_size_inches(4, 3)
201+
plt.tight_layout(w_pad=0)
202+
203+
plt.savefig(f'{self.output_dir}/empirical_fnr.pdf', format='pdf')
196204

197205
# Clear the current figure
198206
plt.clf()

0 commit comments

Comments
 (0)