Puzzles
Practice challenges to sharpen your scikit-learn skills.
Basic Train/Test Split
Split the iris dataset into training and test sets with 80% for training and 20% for testing. Use random_state=42 for reproducibility.
KNN Fit and Predict
Train a K-Nearest Neighbors classifier on the iris dataset and make predictions on the test set.
Build a Confusion Matrix
Create and display a confusion matrix for a classifier's predictions on the iris dataset.
Standardize Features
Use StandardScaler to standardize features so they have zero mean and unit variance.
Cross-Validation Score
Use 5-fold cross-validation to evaluate a Random Forest classifier on the digits dataset.
Build a Simple Pipeline
Create a pipeline that first scales the data and then applies logistic regression.
Grid Search Hyperparameters
Use GridSearchCV to find the best hyperparameters for an SVM classifier.
Extract Feature Importance
Train a Random Forest and extract the feature importances for the wine dataset.
PCA Dimensionality Reduction
Use PCA to reduce the digits dataset from 64 dimensions to 2 and visualize explained variance.
K-Means Clustering
Apply K-Means clustering to the iris dataset and compare cluster labels with true labels.
Plot ROC Curve
Train a classifier and compute the ROC curve and AUC score for binary classification.
Ensemble Voting Classifier
Create a voting classifier that combines multiple different classifiers.
Precision-Recall Trade-off
Calculate precision, recall, and F1-score for different classification thresholds.
Mixed Data Types Pipeline
Use ColumnTransformer to handle numerical and categorical features differently in a pipeline.