Python 中的线性分类器
Michael (Mike) Gelbart
Instructor, The University of British Columbia
x = np.arange(3)
x
array([0, 1, 2])
y = np.arange(3,6)
y
array([3, 4, 5])
x*y
array([0, 4, 10])
np.sum(x*y)
14
x@y
14
x@y 称为 x 与 y 的点积,记作 $x \cdot y$。fit 不同,但 predict 相同$\textrm{原始输出} = \textrm{系数} \cdot \textrm{特征} + \textrm{截距}$
lr = LogisticRegression()
lr.fit(X,y)
lr.predict(X)[10]
0
lr.predict(X)[20]
1
lr.coef_ @ X[10] + lr.intercept_ # raw model output
array([-33.78572166])
lr.coef_ @ X[20] + lr.intercept_ # raw model output
array([ 0.08050621])



Python 中的线性分类器