saving work and wrapping up from the weekend

This commit is contained in:
Tanushree Tunstall 2022-05-23 00:31:02 +01:00
parent 9839b6f8d1
commit 1436557287
3 changed files with 12 additions and 13 deletions

View file

@ -66,7 +66,7 @@ print('\nbest model with feature selection:', fs_bmod)
pipe = Pipeline([
('pre', MinMaxScaler())
('selector', RFECV(LogisticRegression(**rs), cv = skf_cv, scoring = 'matthews_corrcoef'))
, ('selector', RFECV(LogisticRegression(**rs), cv = skf_cv, scoring = 'matthews_corrcoef'))
, ('classifier', LogisticRegression(**rs))])
search_space = [{'selector__min_features_to_select': [1,2]},

View file

@ -73,22 +73,21 @@ parameters = [
# }
{'fs__min_features_to_select': [1,2]},
{'classifier': [LogisticRegression()],
#'classifier__C': np.logspace(0, 4, 10),
'classifier__C': [2, 2.8],
'classifier__max_iter': [100],
'classifier__penalty': ['l1', 'l2'],
'classifier__solver': ['saga']
{'clf': [LogisticRegression(**rs)],
#'clf__C': np.logspace(0, 4, 10),
'clf__C': [2, 2.8],
'clf__max_iter': [100],
'clf__penalty': ['l1', 'l2'],
'clf__solver': ['saga']
}
]
#%% Create pipeline
pipeline = Pipeline([
# ('pre', MinMaxScaler())
('fs', RFECV(LogisticRegression(**rs), scoring = 'matthews_corrcoef'))#cant be my mcc_fn
#, ('clf', ClfSwitcher())
, ('classifier', ClfSwitcher())
('pre', MinMaxScaler())
, ('fs', RFECV(LogisticRegression(**rs), scoring = 'matthews_corrcoef'))#cant be my mcc_fn
#, ('clf', ClfSwitcher()) # gives me slightly lower results
#, ('clf', LogisticRegression(**rs))
])
#%%

View file

@ -62,6 +62,7 @@ Created on Tue Mar 15 11:09:50 2022
################
# NOTE: GS is going into pipeline,
# Cannot get BEST model out
# https://stackoverflow.com/questions/55609339/how-to-perform-feature-selection-with-gridsearchcv-in-sklearn-in-python
################
# Create pipeline
# pipeline = Pipeline([('pre', MinMaxScaler())
@ -144,7 +145,6 @@ param_grid2 = [
'clf__solver': ['saga']
}
]
# step 4: create pipeline
pipeline = Pipeline([