Concepts 🚀 Project 🧮 Labs
🧮 Labs / ML Advanced / Full ML workflow — the senior data scientist's process

Full ML workflow — the senior data scientist's process

Not 'load + fit + predict'. The REAL workflow: 10 steps from raw data to production-ready model. This is what senior DS actually do.

script.py v3.1
Python output click Run to execute
Click "Run" to execute the code on the left.
The output will appear here.
🧠 How it works

10 steps = the real ML workflow. NOT 'load + fit + predict'. STEP 1: UNDERSTAND — shape, nulls, types, distributions, leaks. STEP 2: X/y SPLIT — separate features from target BEFORE processing. STEP 3: TRAIN/TEST SPLIT — BEFORE preprocessing to prevent leakage. If you scale on all data, test data leaks into the scaler → fake high scores. STEP 4: COLUMN TYPES — numerical, nominal (no order), ordinal (has order). STEP 5: PIPELINES — one per type. Impute + scale for numeric, impute + encode for categorical. STEP 6: FULL PIPELINE — chain preprocessing + model. One fit(), one predict(). STEP 7: TRAIN + EVALUATE — report TRAIN + TEST scores. Gap = overfitting. STEP 8: CROSS-VALIDATION — 5-fold CV. More honest than single split. STEP 9: COMPARE MODELS — never trust one model. Try 3+, pick the winner. STEP 10: SAVE THE PIPELINE — preprocessing is BAKED IN. No need to remember the scaler. WHY THIS MATTERS: skip any step = model fails in production. Skip step 3 = data leakage = 99% train, 50% production. Skip step 5 = manual preprocessing = forget a step = crash. Skip step 8 = lucky split = model worse than you think. Skip step 9 = stuck with a bad model = miss easy accuracy. This is the difference between 'I trained a model' (fresher) and 'I built a production ML system' (senior).

✏️ Try these changes
  • Change the model from RandomForestRegressor to GradientBoostingRegressor
    → often higher accuracy on tabular data
  • Add a leak column: df['salary_per_year'] = df['salary'] / df['years_experience'].clip(1)
    → Step 1 should detect it (high correlation with target)
  • Change the imputation strategy from 'median' to 'mean'
    → income is skewed — median is better, mean is pulled by outliers
  • Add Step 9b: hyperparameter tuning with GridSearchCV
    → find the best n_estimators for RandomForest