梯度下降出现在机器学习库的什么地方(例如scikit learn)

Where does gradient descent appear in machine learning libraries (e.g. scikitlearn)

我了解梯度下降的工作原理,并且用户可以手动定义梯度下降函数来最小化某些成本函数。我的问题很笼统,当我们训练和测试线性回归或随机森林等机器学习模型时,GD 出现在 scikitlearn 代码的什么地方? GD 是否简单地嵌入到 .fit() 函数中?或者我们是否需要将其作为参数包含在模型中?

简短回答:大多数 sklearn 模型使用 optimization/fitting 的随机梯度下降。而且您永远不需要指定它。某些函数允许您像 adam.

正如 kate 所说,sklearn 模型使用随机梯度下降,是的,当我们调用 fit 方法时,regressor.fit() 是在优化模型并应用随机梯度下降时。也可以单独调用但是没必要,这里可以help SGD

刚开始使用sklearn时,我也有过同样的困惑。所以线性回归有单独的实现:基于vanillasgd

直接来自 docs:

SGD is merely an optimization technique and does not correspond to a specific family of machine learning models. It is only a way to train a model.

vanilla 实现可以在 class sklearn.linear_model.LinearRegression 中找到,sgd 实现可以在 class sklearn.linear_model.SGDRegressor

中找到

可以找到对应的链接here and here