AI Fundamentals: From Zero to Your First Model • Module D: The Final Project & BeyondLesson 28: Project Workshop — Model Comparison & Tuning
Lesson 28: Project Workshop — Model Comparison & Tuning
Compare multiple models systematically; tune hyperparameters.
Project Workshop: Model Comparison & Tuning
Now that we have a baseline score from our Logistic Regression model, let's see if we can do better by trying different models and tuning their hyperparameters!
Compare Multiple Models
We will test a few different algorithms to see which performs best on our specific dataset. We'll try:
- K-Nearest Neighbors (KNN)
- Decision Trees
- Random Forests
Cross-Validation
To ensure our results are robust and we aren't just getting "lucky" with our train/test split, we will use 5-fold cross-validation to evaluate each model.
Coding Challenge: Hyperparameter Tuning
Let's tune a Random Forest model using Grid Search.
- Set up a
RandomForestClassifier. - Define a parameter grid: try
n_estimatorsof 50 and 100, andmax_depthof 5 and None. - Use
GridSearchCVto find the best combination of parameters using 5-fold cross-validation. - Print the
best_params_and thebest_score_. Does it beat your baseline?