added and ran hyperparam script for all different classifiers, but couldn't successfully run the feature selection and hyperparam together
This commit is contained in:
parent
74af5ef890
commit
37bda41f44
18 changed files with 131 additions and 142 deletions
|
@ -33,8 +33,8 @@ class ClfSwitcher(BaseEstimator):
|
|||
parameters = [
|
||||
{
|
||||
'clf__estimator': [AdaBoostClassifier(**rs)]
|
||||
, 'clf__estimator__n_estimators': [none, 1, 2]
|
||||
, 'clf__estimator__base_estiamtor' : ['None', 1*SVC(), 1*KNeighborsClassifier()]
|
||||
, 'clf__estimator__n_estimators': [1, 2, 5, 10]
|
||||
#, 'clf__estimator__base_estimator' : ['SVC']
|
||||
#, 'clf__estimator___splitter' : ["best", "random"]
|
||||
}
|
||||
]
|
||||
|
@ -48,7 +48,7 @@ pipeline = Pipeline([
|
|||
# Grid search i.e hyperparameter tuning and refitting on mcc
|
||||
gscv_abc = GridSearchCV(pipeline
|
||||
, parameters
|
||||
#, scoring = 'f1', refit = 'f1'
|
||||
#, scoring = 'matthews_corrcoef', refit = 'matthews_corrcoef'
|
||||
, scoring = mcc_score_fn, refit = 'mcc'
|
||||
, cv = skf_cv
|
||||
, **njobs
|
||||
|
@ -64,7 +64,7 @@ gscv_abc_fit_be_res = gscv_abc_fit.cv_results_
|
|||
print('Best model:\n', gscv_abc_fit_be_mod)
|
||||
print('Best models score:\n', gscv_abc_fit.best_score_, ':' , round(gscv_abc_fit.best_score_, 2))
|
||||
|
||||
print('\nMean test score from fit results:', round(mean(gscv_abc_fit_be_re['mean_test_mcc']),2))
|
||||
print('\nMean test score from fit results:', round(mean(gscv_abc_fit_be_res['mean_test_mcc']),2))
|
||||
print('\nMean test score from fit results:', round(np.nanmean(gscv_abc_fit_be_res['mean_test_mcc']),2))
|
||||
|
||||
######################################
|
||||
|
@ -102,17 +102,15 @@ abc_bts_dict['bts_jaccard'] = round(jaccard_score(y_bts, test_predict),2)
|
|||
abc_bts_dict
|
||||
|
||||
# Create a df from dict with all scores
|
||||
pd.DataFrame.from_dict(abc_bts_dict, orient = 'index', columns = 'best_model')
|
||||
|
||||
abc_bts_df = pd.DataFrame.from_dict(abc_bts_dict,orient = 'index')
|
||||
abc_bts_df.columns = ['Logistic_Regression']
|
||||
abc_bts_df.columns = ['ABC']
|
||||
print(abc_bts_df)
|
||||
|
||||
# Create df with best model params
|
||||
model_params = pd.Series(['best_model_params', list(gscv_abc_fit_be_mod.items() )])
|
||||
model_params_df = model_params.to_frame()
|
||||
model_params_df
|
||||
model_params_df.columns = ['Logistic_Regression']
|
||||
model_params_df.columns = ['ABC']
|
||||
model_params_df.columns
|
||||
|
||||
# Combine the df of scores and the best model params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue