I creating a program for assemble methods testing and I have quite a lot of value assigns that are quite the same but names of the values differ. I want to make my code shorter and a bit easier to read and I am wondering how can I create variables with different names in which I assign some values to them in a for loop.
For example I have something like this:
a_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
e_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
p_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
r_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
f1_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
gmean_scores = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
I was thinking of creating a list of names like this:
scores = ['a_scores', 'e_scores', 'p_scores', 'r_scores', 'f1_scores', 'gmean_scores']
and then create a for loop where I assign np.zeros to them. I was thinking of using dictionary but I am not sure if I implement it correctly. a_scores is not defined and I cnt find it
d = {}
for x in enumerate(scores):
d[scores[x]] = np.zeros(shape=(n_datasets, n_splits * n_repeats, n_clfs), dtype=float)
print(a_scores)