To Set Parameters to be Optimized Under the Logistic Regression Model

To Import the StratifiedKFold Class

from sklearn import linear_model, datasets
from sklearn.model_selection import StratifiedKFold
from sklearn.model_selection import train_test_split
k_Fold = StratifiedKFold(n_splits=10, shuffle=True, random_state=0)

To Import the GridSearch Class

from sklearn.model_selection import RandomizedSearchCV

To Set Parameters to be Optimized Under the Logistic Regression Model

logistic_regression = linear_model.LogisticRegression()

alpha = [0.001, 0.01, 0.1, 1, 10, 100, 1000]
activation = ['identity', 'logistic', 'tanh', 'relu'] # should also include l1 but it is necognized for the solver newton-cg.
solver = ['lbfgs', 'saga', 'sag']
parameters = dict(alpha=alpha, activation=activation, solver=solver)

randomized_search = RandomizedSearchCV(estimator = ann,
                                       param_distributions = parameters,
                                       n_iter = 100,
                                       scoring = 'accuracy',
                                       cv = k_Fold,
                                       n_jobs = -1,
                                       random_state = 0)

best_fit = randomized_search.fit(X, Y)
print(randomized_search)
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum