Last active
February 7, 2020 18:15
-
-
Save lazuxd/5f2cd996f9895f9ca24cffbe52e335a2 to your computer and use it in GitHub Desktop.
Building a Sentiment Classifier using Scikit-Learn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Phase 2: penalty and alpha | |
clf = SGDClassifier() | |
distributions = dict( | |
penalty=['l1', 'l2', 'elasticnet'], | |
alpha=uniform(loc=1e-6, scale=1e-4) | |
) | |
random_search_cv = RandomizedSearchCV( | |
estimator=clf, | |
param_distributions=distributions, | |
cv=5, | |
n_iter=50 | |
) | |
random_search_cv.fit(X_train, y_train) | |
print(f'Best params: {random_search_cv.best_params_}') | |
print(f'Best score: {random_search_cv.best_score_}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment