saving work and wrapping up from the weekend
This commit is contained in:
parent
9839b6f8d1
commit
1436557287
3 changed files with 12 additions and 13 deletions
|
@ -66,7 +66,7 @@ print('\nbest model with feature selection:', fs_bmod)
|
||||||
|
|
||||||
pipe = Pipeline([
|
pipe = Pipeline([
|
||||||
('pre', MinMaxScaler())
|
('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))])
|
, ('classifier', LogisticRegression(**rs))])
|
||||||
|
|
||||||
search_space = [{'selector__min_features_to_select': [1,2]},
|
search_space = [{'selector__min_features_to_select': [1,2]},
|
||||||
|
|
|
@ -73,22 +73,21 @@ parameters = [
|
||||||
# }
|
# }
|
||||||
|
|
||||||
{'fs__min_features_to_select': [1,2]},
|
{'fs__min_features_to_select': [1,2]},
|
||||||
{'classifier': [LogisticRegression()],
|
{'clf': [LogisticRegression(**rs)],
|
||||||
#'classifier__C': np.logspace(0, 4, 10),
|
#'clf__C': np.logspace(0, 4, 10),
|
||||||
'classifier__C': [2, 2.8],
|
'clf__C': [2, 2.8],
|
||||||
'classifier__max_iter': [100],
|
'clf__max_iter': [100],
|
||||||
'classifier__penalty': ['l1', 'l2'],
|
'clf__penalty': ['l1', 'l2'],
|
||||||
'classifier__solver': ['saga']
|
'clf__solver': ['saga']
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
#%% Create pipeline
|
#%% Create pipeline
|
||||||
pipeline = Pipeline([
|
pipeline = Pipeline([
|
||||||
# ('pre', MinMaxScaler())
|
('pre', MinMaxScaler())
|
||||||
('fs', RFECV(LogisticRegression(**rs), scoring = 'matthews_corrcoef'))#cant be my mcc_fn
|
, ('fs', RFECV(LogisticRegression(**rs), scoring = 'matthews_corrcoef'))#cant be my mcc_fn
|
||||||
#, ('clf', ClfSwitcher())
|
#, ('clf', ClfSwitcher()) # gives me slightly lower results
|
||||||
, ('classifier', ClfSwitcher())
|
#, ('clf', LogisticRegression(**rs))
|
||||||
|
|
||||||
])
|
])
|
||||||
|
|
||||||
#%%
|
#%%
|
||||||
|
|
|
@ -62,6 +62,7 @@ Created on Tue Mar 15 11:09:50 2022
|
||||||
################
|
################
|
||||||
# NOTE: GS is going into pipeline,
|
# NOTE: GS is going into pipeline,
|
||||||
# Cannot get BEST model out
|
# Cannot get BEST model out
|
||||||
|
# https://stackoverflow.com/questions/55609339/how-to-perform-feature-selection-with-gridsearchcv-in-sklearn-in-python
|
||||||
################
|
################
|
||||||
# Create pipeline
|
# Create pipeline
|
||||||
# pipeline = Pipeline([('pre', MinMaxScaler())
|
# pipeline = Pipeline([('pre', MinMaxScaler())
|
||||||
|
@ -144,7 +145,6 @@ param_grid2 = [
|
||||||
'clf__solver': ['saga']
|
'clf__solver': ['saga']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
# step 4: create pipeline
|
# step 4: create pipeline
|
||||||
pipeline = Pipeline([
|
pipeline = Pipeline([
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue