Get startedGet started for free

Running LogisticRegression and SVC

In this exercise, you'll apply logistic regression and a support vector machine to classify images of handwritten digits.

This exercise is part of the course

Linear Classifiers in Python

View Course

Exercise instructions

  • Apply logistic regression and SVM (using SVC()) to the handwritten digits data set using the provided train/validation split.
  • For each classifier, print out the training and validation accuracy.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

from sklearn import datasets
digits = datasets.load_digits()
X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target)

# Apply logistic regression and print scores
lr = ____
lr.____
print(____)
print(____)

# Apply SVM and print scores
svm = ____
svm.____
print(____)
print(____)
Edit and Run Code