/Stochastic Gradient Descent.py Secret
Created
June 28, 2021 14:21
Star
You must be signed in to star a gist
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
from sklearn.datasets import make_classification | |
from sklearn.linear_model import SGDClassifier | |
from sklearn.model_selection import cross_val_score | |
samples = 500 | |
x, y = make_classification(n_samples=samples, n_features=2, | |
n_informative=2, n_redundant=0, | |
n_clusters_per_class=1) | |
SGD_classifier = SGDClassifier(loss="perceptron", learning_rate="optimal", | |
n_iter_no_change=10) | |
print(cross_val_score(SGD_classifier, x, y, scoring="accuracy", cv=10).mean()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment