¡Bienvenido/a al curso!

Clasificadores lineales en Python

Michael (Mike) Gelbart

Instructor, The University of British Columbia

Conocimientos previos

En este curso suponemos que ya has trabajado con:

  • Python, al nivel de Intermediate Python
  • scikit-learn, al nivel de Supervised Learning with scikit-learn
  • Aprendizaje supervisado, al nivel de Supervised Learning with scikit-learn
Clasificadores lineales en Python

Ajustar y predecir

import sklearn.datasets

newsgroups = sklearn.datasets.fetch_20newsgroups_vectorized()

X, y = newsgroups.data, newsgroups.target
X.shape
(11314, 130107)
y.shape
(11314,)
Clasificadores lineales en Python

Ajustar y predecir (cont.)

from sklearn.neighbors import KNeighborsClassifier

knn = KNeighborsClassifier(n_neighbors=1)
knn.fit(X,y)
y_pred = knn.predict(X)
Clasificadores lineales en Python

Evaluación del modelo

knn.score(X,y)
0.99991
from sklearn.model_selection import train_test_split

X_train, X_test, y_train, y_test = train_test_split(X, y)
knn.fit(X_train, y_train)

knn.score(X_test, y_test)
0.66242
Clasificadores lineales en Python

¡Vamos a practicar!

Clasificadores lineales en Python

Preparing Video For Download...