From 06c32ae2dcfa9ed7ae4af5a9da324f861f2bbf8c Mon Sep 17 00:00:00 2001 From: Piotr Czapla Date: Sat, 18 May 2019 21:59:12 +0200 Subject: [PATCH] Add ability to create folders when saving ensemble output --- ulmfit/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ulmfit/__main__.py b/ulmfit/__main__.py index 36ca9fe..c0d27e4 100644 --- a/ulmfit/__main__.py +++ b/ulmfit/__main__.py @@ -195,7 +195,8 @@ class ULMFiT: print({"Key": key, "Test Accuracy": (test[0] == ensemble).mean(), "on": gold_labels[key], 'files_count':len(files)}) test[0] = ensemble if out_template: - out_file = Template(out_template).substitute(key=key) + out_file = Path(Template(out_template).substitute(key=key)) + out_file.parent.mkdir(exist_ok=True, parents=True) test.to_csv(out_file, header=None) print({"File saved to": out_file})