0

I used GridSearchCV to find the best parameters of Logistic Regression and SVC:

pipe = Pipeline([('scaler', StandardScaler()), ('clf', LogisticRegression())])
cv = StratifiedKFold(n_splits=5, shuffle=True, random_state=11)

param_grid_logreg =   [{'clf': [LogisticRegression(random_state=12)],
                                    'clf__C': 10 ** np.arange(-3.0, 2.0)} ]

grid_search_logreg = GridSearchCV(pipe, 
                           param_grid_logreg,
                           cv=cv)


param_grid_svc =   [{'clf': [SVC(random_state=13)], 
                                'clf__C': 10 ** np.arange(-3.0, 2.0),
                                'clf__kernel': ['linear', 'poly', 'rbf', 'sigmoid']}]

grid_search_svc = GridSearchCV(pipe, 
                           param_grid_svc,
                           cv=cv)
    
grid_search_logreg.fit(Xtrainval, ytrainval)
grid_search_svc.fit(Xtrainval, ytrainval)

Next, I want to combine LogisticRegression and SVC (with previously found best parameters!) according to formula pred_final = alpha * logreg + (1 - alpha) * svc

I want to cross-validate alpha on trainval dataset using previously found grid_search_logreg and grid_search_svc.

What is the best way to do this?

0 Answers0