Mar-08-2021, 12:17 PM
Hello Python community,
I am relatively new the language, and have most of my experience in MATLAB.
I've tried to already search for the answer to my question, however unsuccessfully. Perhaps I am missing the key words...
In any case, I am sure someone could help me rather easily, as I currently feel so:
I have a loop where I set the desired variables first:
Thank you!
I am relatively new the language, and have most of my experience in MATLAB.
I've tried to already search for the answer to my question, however unsuccessfully. Perhaps I am missing the key words...
In any case, I am sure someone could help me rather easily, as I currently feel so:

I have a loop where I set the desired variables first:
feature_ics = {'All': features_all, 'Brain': features_brain, 'Artifact': features_artifact} class_acc_mean = {'All': [], 'Brain': [], 'Artifact': []} class_acc_std = {'All': [], 'Brain': [], 'Artifact': []}Then, at the end of my code, I try to get all of the data I want [the data from 5 iterations of different variables 'j']
logreg_acc_mean[sub_idx] = acc_test_mean logreg_acc_std[sub_idx] = acc_test_std #print(" Accuracy Subject %i: %.2f %%" %(sub_idx, acc_test_mean*100)) # Add results to dictionary print(logreg_acc_mean) print(name) print(j) class_acc_mean[name,j]= logreg_acc_mean class_acc_std[name,j] = logreg_acc_stdAn example output looks like this (Exactly what I want to save!):
Output:------------------------------------------------------------------
Classification Features All
------------------------------------------------------------------
[0.46107143 0.26333333 0.74691176 0.64466667 0.50747253 0.47942857
0.612 0.74142857 0.34580952 0.58695238 0.281 0.46009524
0.29142857]
All
0
------------------------------------------------------------------
[0.45535714 0.22166667 0.59544118 0.60733333 0.32538462 0.50314286
0.48980952 0.64371429 0.40704762 0.60057143 0.183 0.31057143
0.24857143]
All
1
------------------------------------------------------------------
[0.25535714 0.29166667 0.37654412 0.48761905 0.30659341 0.35609524
0.28895238 0.45428571 0.31371429 0.35257143 0.18 0.20666667
0.31428571]
All
2
------------------------------------------------------------------
[0.34464286 0.19666667 0.47654412 0.49152381 0.32098901 0.5107619
0.39695238 0.35152381 0.44238095 0.37857143 0.424 0.3787619
0.39428571]
All
3
------------------------------------------------------------------
[0.47178571 0.225 0.49176471 0.46619048 0.43989011 0.514
0.53657143 0.35304762 0.45904762 0.40542857 0.346 0.3347619
0.33142857]
All
4
.
.
.
Yet, when I then call my variable 'class_acc_mean', I get: Output:.
.
.
('All',
0): array([0.47285714, 0.21166667, 0.50441176, 0.45733333, 0.44494505,
0.52638095, 0.51742857, 0.37219048, 0.45666667, 0.40466667,
0.362 , 0.31085714, 0.32571429]),
('All',
1): array([0.47285714, 0.21166667, 0.50441176, 0.45733333, 0.44494505,
0.52638095, 0.51742857, 0.37219048, 0.45666667, 0.40466667,
0.362 , 0.31085714, 0.32571429]),
('All',
2): array([0.47285714, 0.21166667, 0.50441176, 0.45733333, 0.44494505,
0.52638095, 0.51742857, 0.37219048, 0.45666667, 0.40466667,
0.362 , 0.31085714, 0.32571429]),
('All',
3): array([0.47285714, 0.21166667, 0.50441176, 0.45733333, 0.44494505,
0.52638095, 0.51742857, 0.37219048, 0.45666667, 0.40466667,
0.362 , 0.31085714, 0.32571429]),
('All',
4): array([0.47285714, 0.21166667, 0.50441176, 0.45733333, 0.44494505,
0.52638095, 0.51742857, 0.37219048, 0.45666667, 0.40466667,
0.362 , 0.31085714, 0.32571429]),
.
.
.
Why does 'j' seem to update in my code, but then not save in the variable? How can I save the relevant data for each loop, as in the output during the code run itself? This is seemingly so simple but it's been driving me a bit mad.Thank you!