HomeCoursesLinear classifiers in Python

Comparing model performance

Chapter 2 · Putting logistic regression and SVMs into practice · lesson 4 of 46
Reserved for subscribers — here is the beginning
Comparing models Compare k-nearest neighbors classifiers with k=1 and k=5 on the handwritten digits dataset, already loaded into the variables X_train, y_train, X_test and y_test. You can set k with the n_neighbors parameter when creating the KNeighborsClassifier object, which is also already imported into the environment. Which model achieves the best accuracy on the test data? Instructions 35 XP Possible answers k=1 k=5 Hint Create the two classifiers with KNeighborsClassifier(n_neighbors=1) and KNeighborsClassifier(n_neighbors=5). Then train them and evaluate their score.
The rest of this lesson is reserved for subscribers Create your free account to try the sample exercises, then upgrade to full access whenever you like.

Create your free account

No credit card required, in thirty seconds.
Continue with Google
or
Sign up with an e-mail
Already registered? Log in
By continuing, you agree to the terms of use and the privacy policy. Your data is hosted in the European Union.

Full access DATAGOZ

19 €/ month — or 190 € / year
  • All published courses and career paths
  • Exercises and quizzes with automatic grading
  • Practice, exam and certificate of completion
  • No commitment, cancel online
See the plans
This lesson is part of the course

Linear Classifiers in Python

short_training6 chapters · 46 lessons
  • The training platformsubscribers
  • Review of the fundamentals of scikit-learnsubscribers
  • Discover KNN classificationsubscribers
  • Comparing model performanceyou are here
  • Understand overfittingsubscribers
  • Apply logistic regression and SVMssubscribers
  • Use LogisticRegression and SVCsubscribers
  • Perform sentiment analysis on movie reviewssubscribers
  • Understand linear classifierssubscribers
  • Identify linear decision boundariessubscribers
  • Visualize decision boundariessubscribers
  • Study the coefficients of linear classifierssubscribers
  • Understand how models make their predictionssubscribers
  • Modify a model's coefficientssubscribers
  • Discover the concept of loss functionsubscribers
  • Understand the 0-1 loss functionsubscribers
  • Learn how to minimize a loss functionsubscribers
  • Visualize the different loss functionssubscribers
  • Explore loss functions in classificationsubscribers
  • Compare the logistic and hinge loss functionssubscribers
  • Implement a logistic regression modelsubscribers
  • Understanding regularization in logistic regressionsubscribers
  • Implement a regularized logistic regressionsubscribers
  • Using logistic regression to select variablessubscribers
  • Identifying the most positive and most negative wordssubscribers
  • Understanding probabilities in logistic regressionsubscribers
  • Extracting class membership probabilitiessubscribers
  • Studying the effect of regularization on probabilitiessubscribers
  • Visualizing simple and complex classification examplessubscribers
  • Discovering multiclass logistic regressionsubscribers
  • Determining the number of coefficientssubscribers
  • Fit a multiclass logistic regression modelsubscribers
  • Visualize the results of multiclass logistic regressionsubscribers
  • Apply the one-vs-all SVM strategysubscribers
  • Understand support vectorssubscribers
  • Identify support vectorssubscribers
  • Study the effect of removing certain observationssubscribers
  • Discover kernel SVMssubscribers
  • Get started with GridSearchCVsubscribers
  • Optimize the gamma and C parameters simultaneously with GridSearchCVsubscribers
  • Compare logistic regression, SVMs and other methodssubscribers
  • Identify the advantages of SVMssubscribers
  • Identify the advantages of logistic regressionsubscribers
  • Using the SGDClassifier modelsubscribers
  • In conclusionsubscribers
  • Course conclusionsubscribers
Next lesson

Understanding overfitting

View the programme Create an account to continue