I want to improve my code. It performs 4 cross-validations: 10x20, 10x10, 10x5 10x2. Then it stores the values in Pandas where I will get the average of each column and multiply them by 100.You will notice than in order to get the 4 cross-validations, I have to repeat the code 4 times. Is there a way to avoid that? Would it be possible to add more cross-validations (ex: 5x2, 10x15) without having to repeat the code each time?So here come my code and the Pandas table:*xSSSmean20, xSSSmean10, xSSSmean5, xSSSmean2: here I store the average of the inner loops. At the end, each one, will have 10 values.*result_list: here I store xSSSmean20, xSSSmean10, xSSSmean5 and xSSSmean2result_list = [] from sklearn.ensemble import RandomForestClassifierclf = RandomForestClassifier(n_estimators = 10) #######################10x20 SSS#######################from sklearn.cross_validation import StratifiedShuffleSplitxSSSmean20 = [] for i in range(10):    sss = StratifiedShuffleSplit(y, 20, test_size=0.1, random_state=0)    scoresSSS = cross_validation.cross_val_score(clf, x, y , cv=sss)    xSSSmean20.append(scoresSSS.mean())result_list.append(xSSSmean20)#######################10x10 SSS#######################xSSSmean10 = [] for i in range(10):    sss = StratifiedShuffleSplit(y, 10, test_size=0.1, random_state=0)    scoresSSS = cross_validation.cross_val_score(clf, x, y , cv=sss)    xSSSmean10.append(scoresSSS.mean())result_list.append(xSSSmean10)#######################10x5 SSS#######################xSSSmean5 = [] for i in range(10):    sss = StratifiedShuffleSplit(y, 5, test_size=0.1, random_state=0)    scoresSSS = cross_validation.cross_val_score(clf, x, y , cv=sss)    xSSSmean5.append(scoresSSS.mean())result_list.append(xSSSmean5)#######################10x2 SSS#######################xSSSmean2 = [] for i in range(10):    sss = StratifiedShuffleSplit(y, 2, test_size=0.1, random_state=0)    scoresSSS = cross_validation.cross_val_score(clf, x, y , cv=sss)    xSSSmean2.append(scoresSSS.mean())result_list.append(xSSSmean2)table= (np.vstack(result_list)).Timport pandas as pddf = pd.DataFrame(table, columns=('10x20', '10x10', '10x5', '10x2')) df.loc['Total Accuracy'] = df.mean() df.round(4)*100 
Sending the accuracies of 4 cross-validations to a pandas dataframe
python;python 3.x;pandas;machine learning