Skip to content

Instantly share code, notes, and snippets.

@mohcinemadkour
Forked from terrah27/sgd_grid.py
Created August 12, 2019 14:42
Show Gist options
  • Save mohcinemadkour/e4a26589d6c6e8741059e920e86bc844 to your computer and use it in GitHub Desktop.
Save mohcinemadkour/e4a26589d6c6e8741059e920e86bc844 to your computer and use it in GitHub Desktop.
loss = ['hinge', 'log', 'modified_huber', 'squared_hinge', 'perceptron']
penalty = ['l1', 'l2', 'elasticnet']
alpha = [0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000]
learning_rate = ['constant', 'optimal', 'invscaling', 'adaptive']
class_weight = [{1:0.5, 0:0.5}, {1:0.4, 0:0.6}, {1:0.6, 0:0.4}, {1:0.7, 0:0.3}]
eta0 = [1, 10, 100]
param_distributions = dict(loss=loss,
penalty=penalty,
alpha=alpha,
learning_rate=learning_rate,
class_weight=class_weight,
eta0=eta0)
random = RandomizedSearchCV(estimator=sgd,
param_distributions=param_distributions,
scoring='roc_auc',
verbose=1, n_jobs=-1,
n_iter=1000)
random_result = random.fit(X_train, y_train)
print('Best Score: ', random_result.best_score_)
print('Best Params: ', random_result.best_params_)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment