saving work

This commit is contained in:
Tanushree Tunstall 2022-07-01 20:37:41 +01:00
parent d812835713
commit b5777a17c9
3 changed files with 103 additions and 22 deletions

View file

@ -77,6 +77,7 @@ import re
#####################################
rs = {'random_state': 42}
njobs = {'n_jobs': 10}
scoring_fn = ({ 'mcc' : make_scorer(matthews_corrcoef)
, 'fscore' : make_scorer(f1_score)
@ -87,6 +88,9 @@ scoring_fn = ({ 'mcc' : make_scorer(matthews_corrcoef)
, 'jcc' : make_scorer(jaccard_score)
})
mcc_score_fn = {'mcc': make_scorer(matthews_corrcoef)}
jacc_score_fn = {'jcc': make_scorer(jaccard_score)}
skf_cv = StratifiedKFold(n_splits = 10
#, shuffle = False, random_state= None)
, shuffle = True,**rs)
@ -95,9 +99,6 @@ rskf_cv = RepeatedStratifiedKFold(n_splits = 10
, n_repeats = 3
, **rs)
mcc_score_fn = {'mcc': make_scorer(matthews_corrcoef)}
jacc_score_fn = {'jcc': make_scorer(jaccard_score)}
###############################################################################
def fsgs_rfecv(input_df
, target
@ -109,7 +110,10 @@ def fsgs_rfecv(input_df
, custom_fs = RFECV(DecisionTreeClassifier(**rs) , cv = skf_cv, scoring = 'matthews_corrcoef')
, cv_method = skf_cv
, var_type = ['numerical', 'categorical' , 'mixed']
, resampling_type = 'none'
, verbose = 3
, random_state = 42
, n_jobs = 10
):
'''
returns
@ -120,6 +124,10 @@ def fsgs_rfecv(input_df
optimised/selected based on mcc
'''
rs = {'random_state': random_state}
njobs = {'n_jobs': n_jobs}
###########################################################################
#================================================
# Determine categorical and numerical features
@ -375,6 +383,8 @@ def fsgs_rfecv(input_df
output_modelD['train_score (MCC)'] = train_bscore
output_modelD['bts_mcc'] = bts_mcc_score
output_modelD['train_bts_diff'] = round(train_test_diff,2)
output_modelD['resampling'] = resampling_type
print(output_modelD)
nlen = len(output_modelD)