Month 2 — Exercises set
🟢 Easy
Algorithms
load_iris(),load_wine(),load_breast_cancer()— for each one, train 3 different models and compare accuracy.LogisticRegression,KNN,SVM,DecisionTree,RandomForest— evaluate all withcross_val_score.- Determine for each model whether feature scaling is needed or not (compare with Pipeline + StandardScaler vs without).
Metrics
- Compute confusion matrix by hand and verify with
sklearn.metrics.confusion_matrix. - Compute Precision, Recall, F1 manually using the formulas.
- Show the difference between
predictandpredict_proba, change threshold to change accuracy.
Pipeline
- Create
Pipeline([scaler, model])and runfit_predict. - Process numeric and categorical columns separately with
ColumnTransformer. - Save Pipeline with
joblib.dumpand reload it.
🟡 Medium
Real datasets
- Titanic: Get 80%+ accuracy with Pipeline + Random Forest.
- House Prices: Compare Lasso + Ridge, achieve R² 0.85+.
- Telco Churn: Combat imbalanced data, achieve F1 0.6+.
- Wine Quality: Compare regression vs classification approaches.
Feature Engineering
- NYC Taxi: Create 10+ features from datetime and observe RF accuracy improvement.
- Text feature engineering: Enrich one categorical column with
n-gram. - Polynomial features: Experiment with degree=2, observe overfitting.
Hyperparameter Tuning
- With
GridSearchCVXGBoost 3 parameters — how long for 100 trials? - Same thing with
RandomizedSearchCV— time and quality difference? - With
Optuna100 trials — best and fastest!
Ensembles
- RF vs XGBoost vs LightGBM vs CatBoost — compare on the same dataset (table).
- Voting Classifier (3 models) — is it better than each one’s individual result?
- Stacking — create base + meta.
🔴 Hard (Production)
1. Churn Prediction Service
Full requirements:
- Django REST Framework or FastAPI
- PostgreSQL
customertable (50+ features) /api/v1/predict/churn/{customer_id}— fetch features from DB + prediction/api/v1/predict/churn/batch— CSV upload + Celery background/api/v1/feedback— return real outcome (for model improvement)/api/v1/metrics— Prometheus format- Docker + docker-compose
- GitHub Actions CI/CD
2. AutoML Service
Upload a dataset and automatically:
- EDA report (ydata-profiling)
- Compare 5+ algorithms
- Save the best model
- Prediction endpoint automatically ready
Inspiration: H2O AutoML, PyCaret.
3. A/B Testing Backend
- Serve two models (
v1andv2) - Random traffic split (60/40 or configurable)
- Log each prediction to Postgres
- Automatically determine which model is better with a statistical test
- Slack notification: “Model v2 wins!”
4. Real-time Anomaly Detection
- Kafka consumer (transaction stream)
- Online anomaly detection with IsolationForest or DBSCAN
- Send anomalies to a separate Kafka topic
- Grafana dashboard
Mini-projects
Mini-project 1: Spam Classifier
- SMS Spam dataset (UCI)
- TF-IDF + Logistic Regression / Naive Bayes
- FastAPI endpoint
- Streamlit UI
Mini-project 2: Stock Price Direction
- Stock data with yfinance
- Technical indicators (RSI, MACD) feature engineering
- Up/Down classification
- Backtesting
Mini-project 3: Recommendation System (Collaborative Filtering)
- MovieLens dataset
- Surprise library
- User-based and item-based
- API:
/recommend/{user_id}
Mini-project 4: Time Series Forecasting
- Prophet or ARIMA
- Daily sales forecasting
- 30-day prediction
Quiz
ML Fundamentals
- Difference between Supervised and Unsupervised?
- Explain the Bias-Variance tradeoff with an example.
- How do you detect overfitting?
- Why is cross-validation needed?
- Why 3 in Train/Val/Test split?
Algorithms
- Why the word “regression” in Logistic Regression’s name? (Hint: log-odds)
- What does the
kparameter affect in KNN? - Difference between Random Forest and Gradient Boosting (parallel vs sequential)?
- Main difference between XGBoost and LightGBM?
- Why is CatBoost’s categorical handling better?
Metrics
- Why is accuracy a poor metric for imbalanced classification?
- When do ROC-AUC and PR-AUC differ?
- Difference between F1 and F-beta?
- In regression, when do you use MAE vs MSE?
- Can R² be negative? Why?
Production
- Difference between
joblibandpickle? - How do you containerize an ML model with Docker?
- What is model drift and how is it detected? (preview, Month 6)
- Why is ONNX useful?
- What is statistical significance in A/B testing?
✅ Month 2 final checklist
- Used most of the classical ML algorithms
- Mastered Scikit-learn Pipeline and ColumnTransformer
- Worked with XGBoost/LightGBM (at least 1 competition)
- Did hyperparameter tuning with Optuna
- Interpreted models with SHAP or Feature Importance
- Deployed ML model to production with FastAPI
- Made first Kaggle submission (top 30%)
- Capstone project on GitHub
- LinkedIn post (project + certificate)
Congratulations! Moving on to Month 3 — Deep Learning.