Clasificadores lineales: ecuaciones de predicción

Clasificadores lineales en Python

Michael (Mike) Gelbart

Instructor, The University of British Columbia

Productos punto

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 se llama producto punto de x y y, y se escribe $x \cdot y$.
Clasificadores lineales en Python

Predicción con un clasificador lineal

  • $\textrm{raw model output} = \textrm{coefficients} \cdot \textrm{features} + \textrm{intercept}$
  • Predicción con clasificador lineal: calcula la salida bruta y mira el signo
    • si es positivo, predice una clase
    • si es negativo, predice la otra clase
  • Igual para regresión logística y SVM lineal
    • fit cambia, pero predict es igual
Clasificadores lineales en Python

Cómo predice 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
Clasificadores lineales en Python

Cómo predice LogisticRegression (cont.)

lr.coef_ @ X[10] + lr.intercept_ # raw model output
array([-33.78572166])
lr.coef_ @ X[20] + lr.intercept_ # raw model output
array([ 0.08050621])
Clasificadores lineales en Python

La salida bruta del modelo

Clasificadores lineales en Python

La salida bruta del modelo

Clasificadores lineales en Python

La salida bruta del modelo

Clasificadores lineales en Python

¡Vamos a practicar!

Clasificadores lineales en Python

Preparing Video For Download...