added cm_logo_skf.py and placeholder for splits

This commit is contained in:
Tanushree Tunstall 2022-07-01 13:55:12 +01:00
parent 952cfeb4c0
commit d812835713
4 changed files with 254 additions and 49 deletions

View file

@ -89,14 +89,7 @@ scoring_fn = ({ 'mcc' : make_scorer(matthews_corrcoef)
, 'jcc' : make_scorer(jaccard_score)
})
skf_cv = StratifiedKFold(n_splits = 10
#, shuffle = False, random_state= None)
, shuffle = True,**rs)
rskf_cv = RepeatedStratifiedKFold(n_splits = 10
, n_repeats = 3
, **rs)
logo = LeaveOneGroupOut()
mcc_score_fn = {'mcc': make_scorer(matthews_corrcoef)}
jacc_score_fn = {'jcc': make_scorer(jaccard_score)}
@ -160,7 +153,10 @@ def MultModelsCl_logo_skf(input_df
, add_yn = True # adds target var class numbers
, var_type = ['numerical', 'categorical','mixed']
, run_blind_test = True
, return_formatted_output = True):
, return_formatted_output = True
, random_state = 42
, n_jobs = 10
, ):
'''
@ param input_df: input features
@ -179,10 +175,24 @@ def MultModelsCl_logo_skf(input_df
Dict containing multiple classification scores for each model and mean of each Stratified Kfold including training
'''
# if group == 'none':
# sel_cv = skf_cv
# else:
# group = 'none'
#%% Func globals
rs = {'random_state': random_state}
njobs = {'n_jobs': n_jobs}
skf_cv = StratifiedKFold(n_splits = 10
#, shuffle = False, random_state= None)
, shuffle = True,**rs)
rskf_cv = RepeatedStratifiedKFold(n_splits = 10
, n_repeats = 3
, **rs)
logo = LeaveOneGroupOut()
# select CV type:
if group == 'none':
sel_cv = skf_cv
else:
sel_cv = logo
#======================================================
# Determine categorical and numerical features
#======================================================
@ -210,7 +220,7 @@ def MultModelsCl_logo_skf(input_df
#======================================================
# Specify multiple Classification Models
#======================================================
models = [('AdaBoost Classifier' , AdaBoostClassifier(**rs) )
models = [('AdaBoost Classifier' , AdaBoostClassifier(**rs) )
, ('Bagging Classifier' , BaggingClassifier(**rs, **njobs, bootstrap = True, oob_score = True) )
, ('Decision Tree' , DecisionTreeClassifier(**rs) )
, ('Extra Tree' , ExtraTreeClassifier(**rs) )