선형 분류기: 예측 방정식

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@yxy의 내적(dot product)이며, $x \cdot y$로 표기합니다.
Python으로 배우는 선형 분류기

선형 분류기 예측

  • $\textrm{raw model output} = \textrm{coefficients} \cdot \textrm{features} + \textrm{intercept}$
  • 선형 분류기 예측: 원시 모델 출력을 계산하고 부호를 확인
    • 양수이면 한 클래스로 예측
    • 음수이면 다른 클래스로 예측
  • 로지스틱 회귀와 선형 SVM에서 동일하게 적용
    • fit은 다르지만 predict는 동일
Python으로 배우는 선형 분류기

LogisticRegression의 예측 방식

$\textrm{raw model output} = \textrm{coefficients} \cdot \textrm{features} + \textrm{intercept}$

lr = LogisticRegression()

lr.fit(X,y)

lr.predict(X)[10]
0
lr.predict(X)[20]
1
Python으로 배우는 선형 분류기

LogisticRegression의 예측 방식 (계속)

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으로 배우는 선형 분류기

원시 모델 출력

Python으로 배우는 선형 분류기

원시 모델 출력

Python으로 배우는 선형 분류기

원시 모델 출력

Python으로 배우는 선형 분류기

연습해 봅시다!

Python으로 배우는 선형 분류기

Preparing Video For Download...