【发布时间】:2021-05-04 01:58:52
【问题描述】:
在训练逻辑回归时,它会经历一个迭代过程,在每个过程中,它都会计算 x 变量的权重和偏差值以最小化损失函数。
来自sklearn官方代码class LogisticRegression | linear model in scikit-learn,逻辑回归类的拟合方法如下
def fit(self, X, y, sample_weight=None):
"""
Fit the model according to the given training data.
Parameters
----------
X : {array-like, sparse matrix} of shape (n_samples, n_features)
Training vector, where n_samples is the number of samples and
n_features is the number of features.
y : array-like of shape (n_samples,)
Target vector relative to X.
sample_weight : array-like of shape (n_samples,) default=None
Array of weights that are assigned to individual samples.
If not provided, then each sample is given unit weight.
.. versionadded:: 0.17
*sample_weight* support to LogisticRegression.
我猜sample_weight = weight 的 x 个变量如果没有被设置为 1,那么偏差值是否也是 1?
【问题讨论】:
标签: python scikit-learn logistic-regression