saving work
This commit is contained in:
parent
d812835713
commit
b5777a17c9
3 changed files with 103 additions and 22 deletions
|
@ -77,9 +77,6 @@ import re
|
|||
import itertools
|
||||
from sklearn.model_selection import LeaveOneGroupOut
|
||||
#%% GLOBALS
|
||||
rs = {'random_state': 42}
|
||||
njobs = {'n_jobs': 10}
|
||||
|
||||
scoring_fn = ({ 'mcc' : make_scorer(matthews_corrcoef)
|
||||
, 'fscore' : make_scorer(f1_score)
|
||||
, 'precision' : make_scorer(precision_score)
|
||||
|
@ -146,7 +143,7 @@ def MultModelsCl_logo_skf(input_df
|
|||
, blind_test_df = pd.DataFrame()
|
||||
, blind_test_target = pd.Series(dtype = int)
|
||||
, tts_split_type = "none"
|
||||
, group = 'none'
|
||||
#, group = 'none'
|
||||
|
||||
, resampling_type = 'none' # default
|
||||
, add_cm = True # adds confusion matrix based on cross_val_predict
|
||||
|
@ -188,11 +185,11 @@ def MultModelsCl_logo_skf(input_df
|
|||
, **rs)
|
||||
logo = LeaveOneGroupOut()
|
||||
|
||||
# select CV type:
|
||||
if group == 'none':
|
||||
sel_cv = skf_cv
|
||||
else:
|
||||
sel_cv = logo
|
||||
# # select CV type:
|
||||
# if group == 'none':
|
||||
# sel_cv = skf_cv
|
||||
# else:
|
||||
# sel_cv = logo
|
||||
#======================================================
|
||||
# Determine categorical and numerical features
|
||||
#======================================================
|
||||
|
@ -277,7 +274,7 @@ def MultModelsCl_logo_skf(input_df
|
|||
, input_df
|
||||
, target
|
||||
, cv = sel_cv
|
||||
, groups = group
|
||||
#, groups = group
|
||||
, scoring = scoring_fn
|
||||
, return_train_score = True)
|
||||
#==============================
|
||||
|
@ -306,7 +303,12 @@ def MultModelsCl_logo_skf(input_df
|
|||
cmD = {}
|
||||
|
||||
# Calculate cm
|
||||
y_pred = cross_val_predict(model_pipeline, input_df, target, cv = sel_cv, groups = group, **njobs)
|
||||
y_pred = cross_val_predict(model_pipeline
|
||||
, input_df
|
||||
, target
|
||||
, cv = sel_cv
|
||||
#, groups = group
|
||||
, **njobs)
|
||||
#_tn, _fp, _fn, _tp = confusion_matrix(y_pred, y).ravel() # internally
|
||||
tn, fp, fn, tp = confusion_matrix(y_pred, target).ravel()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue