from sklearn.linear_model import SGDClassifier
X = [[0, 0], [1, 1]]
y = [0, 1]
clf = SGDClassifier(loss='hinge', penalty='l2')
clf.fit(X, y)

clf.predict([[2., 2.]])

clf.coef_

#To get the signed distance to the hyperplane
clf.decision_function([[2., 2.]])

"""
Explanation: Stochastic Gradient Descent l
That is a simple yet very efficient approach to discriminative learning of linear classifiers under convex loss function such as(linear) Support Vector Machine and Logistic Regression.
1 Introdution
The advantages of Stochastic Gradient Desent are:
+ Efficiency
+ Ease of implementation  
The disadvantages of SGD 
+ SGD requiress a number of hyperparamters such as the regularization and the number of iterations
+ SGD is senstive to feature scaling
2 Classification
End of explanation
"""


clf = SGDClassifier(loss='log').fit(X, y)
clf.predict_proba([[1., 1.]])

"""
Explanation: The concrete loss function can be set via the loss paramters, 
+ loss = 'hinge': soft-margin linear Support Vector Machine
+ loss = 'modified_huber': smooth hinge loss
+ loss = 'log' : logistic regression  
Using loss = 'log' or loss='modified_huber' enables the predict_proba method, which gives a vector of probabilty estimates $P(y \rvert x) $per sample x:
End of explanation
"""


from sklearn.preprocessing import StandardScaler
sclarer = StandardScaler()
sclarer.fit(X_train)
sclarer.fit(X_test)

"""
Explanation: 3 Tips
Scale each attribute ont the input vector X to [0,1] or [-1,+1], or standardize it to have mean 0 and variance 1. and the same scaling must be applied to the test vector to obtain meaningful results.
End of explanation
"""


