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
|
@ -32,10 +32,9 @@ class ClfSwitcher(BaseEstimator):
|
|||
|
||||
parameters = [
|
||||
{
|
||||
'clf__estimator': [KNeighborsClassifier(**rs
|
||||
, **njobs]
|
||||
#, 'clf__estimator__n_neighbors': range(1, 21, 2)
|
||||
, 'clf__estimator__n_neighbors': [5, 7, 11]
|
||||
'clf__estimator': [KNeighborsClassifier(**njobs)]
|
||||
, 'clf__estimator__n_neighbors': range(21, 51, 2)
|
||||
#, 'clf__estimator__n_neighbors': [5, 7, 11]
|
||||
, 'clf__estimator__metric' : ['euclidean', 'manhattan', 'minkowski']
|
||||
, 'clf__estimator__weights' : ['uniform', 'distance']
|
||||
|
||||
|
@ -67,7 +66,7 @@ gscv_knn_fit_be_res = gscv_knn_fit.cv_results_
|
|||
print('Best model:\n', gscv_knn_fit_be_mod)
|
||||
print('Best models score:\n', gscv_knn_fit.best_score_, ':' , round(gscv_knn_fit.best_score_, 2))
|
||||
|
||||
print('\nMean test score from fit results:', round(mean(gscv_knn_fit_be_re['mean_test_mcc']),2))
|
||||
print('\nMean test score from fit results:', round(mean(gscv_knn_fit_be_res['mean_test_mcc']),2))
|
||||
print('\nMean test score from fit results:', round(np.nanmean(gscv_knn_fit_be_res['mean_test_mcc']),2))
|
||||
|
||||
######################################
|
||||
|
@ -105,17 +104,15 @@ knn_bts_dict['bts_jaccard'] = round(jaccard_score(y_bts, test_predict),2)
|
|||
knn_bts_dict
|
||||
|
||||
# Create a df from dict with all scores
|
||||
pd.DataFrame.from_dict(knn_bts_dict, orient = 'index', columns = 'best_model')
|
||||
|
||||
knn_bts_df = pd.DataFrame.from_dict(knn_bts_dict,orient = 'index')
|
||||
knn_bts_df.columns = ['Logistic_Regression']
|
||||
knn_bts_df.columns = ['KNN']
|
||||
print(knn_bts_df)
|
||||
|
||||
# Create df with best model params
|
||||
model_params = pd.Series(['best_model_params', list(gscv_knn_fit_be_mod.items() )])
|
||||
model_params_df = model_params.to_frame()
|
||||
model_params_df
|
||||
model_params_df.columns = ['Logistic_Regression']
|
||||
model_params_df.columns = ['KNN']
|
||||
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