Commit 3b7e63994c7b1b562f19ca10c9c7b3b472483644
1 parent
15b183a24d
Exists in
master
Reajust the way to name files using prefix
Showing 1 changed file with 4 additions and 4 deletions Side-by-side Diff
scripts/evaluations/clustering.py
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | estimator.fit(feats) |
41 | 41 | print(f"Kmeans: processed {estimator.n_iter_} iterations - intertia={estimator.inertia_}") |
42 | 42 | |
43 | - with open(os.path.join(outdir, f"_kmeans.pkl"), "wb") as f: | |
43 | + with open(os.path.join(outdir, f"{args.prefix}kmeans.pkl"), "wb") as f: | |
44 | 44 | pickle.dump(estimator, f) |
45 | 45 | |
46 | 46 | # contains distance to each cluster for each sample |
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 | K = purity_scores["K"] |
85 | 85 | |
86 | 86 | # Write results |
87 | - with open(os.path.join(outdir, f"_" + args.prefix + "eval_clustering.log"), "w") as fd: | |
87 | + with open(os.path.join(outdir, args.prefix + "eval_clustering.log"), "w") as fd: | |
88 | 88 | print(f"F1-scores for each classes:\n{fscores_str}", file=fd) |
89 | 89 | print(f"Entropy: {entropy}", file=fd) |
90 | 90 | print(f"Global score : {np.mean(fscores)}", file=fd) |
... | ... | @@ -212,7 +212,7 @@ |
212 | 212 | |
213 | 213 | |
214 | 214 | # File with results |
215 | - file_results = os.path.join(args.outdir, "clustering_measures.txt") | |
215 | + file_results = os.path.join(args.outdir, args.prefix + "clustering_measures.txt") | |
216 | 216 | |
217 | 217 | with open(file_results, "w") as f: |
218 | 218 | f.write(f"[nmodels: {args.nmodels}]\n") |
... | ... | @@ -223,7 +223,7 @@ |
223 | 223 | f.write(f"[{key} => mean: {mean}, std: {std}] \n") |
224 | 224 | |
225 | 225 | # CSV File with all the values |
226 | - file_csv_measures = os.path.join(args.outdir, "clustering_measures.csv") | |
226 | + file_csv_measures = os.path.join(args.outdir, args.prefix + "clustering_measures.csv") | |
227 | 227 | |
228 | 228 | with open(file_csv_measures, "w", newline="") as f: |
229 | 229 | writer = csv.writer(f, delimiter=",") |