SGDClassifier vs LogisticRegression with sgd solver in scikit-learn library

Viewed 13255

scikit-learn library has following classifiers which look similar:

  • Logistic regression classifier has different solvers and one of them is 'sgd'

http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression

  • It also has a different classifier 'SGDClassifier' and the loss parameter can be mentioned as 'log' for logistic regression.

http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier

Are they essentially same or different? If they are different, how different is the implementation between two? And how do you decide which one to use given the problem of logistic regression?

3 Answers

Basically, SGD is like an umbrella capable to facing different linear functions. SGD is an approximation algorithm like taking single single points and as the number of point increases it converses more to the optimal solution. Therefore, it is mostly used when the dataset is large. Logistic Regression uses Gradient descent by default so its slower (if compared on large dataset) To make SGD perform well for any particular linear function, lets say here logistic Regression we tune the parameters called hyperparameter tuning

Related