Leo followed Machine Learning: sklearn the Stochastic Gradient Descent

sklearn framework

Here Insert Picture Description

Mapping function

Here Insert Picture Description

1.5.1. Classification

from sklearn.linear_model import SGDClassifier
X = [[0., 0.], [1., 1.]]
y = [0, 1]
clf = SGDClassifier(loss="hinge", penalty="l2", max_iter=5)
clf.fit(X, y)
clf.predict([[2., 2.]])
clf.coef_
clf = SGDClassifier(loss="log", max_iter=5).fit(X, y)
clf.predict_proba([[1., 1.]])

1.5.2. Regression

Parameter changes:

loss=“squared_loss”: Ordinary least squares,
loss=“huber”: Huber loss for robust regression,
loss=“epsilon_insensitive”: linear Support Vector Regression.

Published 17 original articles · won praise 0 · Views 139

Guess you like

Origin blog.csdn.net/weixin_39025679/article/details/104474311