CTCaliberTek
Course: Data Science with Python: Step by Step · Lesson 8 of 8Log in to track your progress and earn a certificate when you finish the course.
Data Engineering & Analytics

Data Science with Python Module 8: From Notebook to a Finished Project

Published October 25, 2026·Updated October 29, 2026·9 min read

Edited by , Senior Data Analyst. How we make our content

Like SaveLog in to like, save, and track progress.

Introduction

A model in a notebook helps nobody until it is reproducible, saved, and explained. This final module shows how to organize a project, save a trained pipeline, load it to make predictions, and present the findings. It ends with a capstone project you can put in a portfolio.

Prerequisites

  • Modules 1 to 7 completed

Step-by-Step Guide

Step 1: Organize the project

A simple structure keeps raw data separate from cleaned data and moves reusable code out of notebooks into modules. Pin your library versions in requirements.txt and set random seeds, so someone else can reproduce your results.

ds-project/
  data/
    raw/            # never edited by hand
    processed/
  notebooks/        # exploration and reports
  src/
    features.py     # cleaning and feature functions
    train.py        # trains and saves the model
    predict.py      # loads the model and predicts
  models/
  requirements.txt
  README.md         # the question, the data, how to run, results

Step 2: Train and save a pipeline

Save the whole pipeline, including preprocessing, so predictions use exactly the steps used in training. joblib is the usual tool for scikit-learn objects. Only load model files you created or trust, because loading pickled objects can run code.

import joblib
from sklearn.datasets import load_breast_cancer
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

X, y = load_breast_cancer(return_X_y=True, as_frame=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)

model = make_pipeline(StandardScaler(), RandomForestClassifier(n_estimators=200, random_state=42))
model.fit(X_train, y_train)
print("test accuracy:", round(model.score(X_test, y_test), 3))

joblib.dump(model, "model.joblib")

Step 3: Load the model and predict

Wrap prediction in a small function that checks its input. Validate column names, because a wrong order or a missing feature silently gives wrong answers. This function is the piece a web service, a scheduled job, or a dashboard would call.

import joblib
import pandas as pd

model = joblib.load("model.joblib")
EXPECTED = list(X.columns)

def predict(rows: pd.DataFrame):
    missing = set(EXPECTED) - set(rows.columns)
    if missing:
        raise ValueError("missing columns: " + ", ".join(sorted(missing)))
    rows = rows[EXPECTED]
    return model.predict(rows), model.predict_proba(rows)[:, 1]

labels, probability = predict(X_test.head(3))
print(labels, probability.round(3))

Step 4: Communicate your results

Lead with the answer to the question, then show the evidence. Use one clear chart per point with labeled axes, state the limits and assumptions, and explain what the model should and should not be used for. Translate metrics into business terms such as how many cases are caught and how many false alarms result.

Report outline
1. The question and why it matters
2. The data (source, size, time period, known problems)
3. What we found (3 key results, each with one chart)
4. The model (what it predicts, how well, compared with the baseline)
5. Limits and risks (bias, missing data, when it will fail)
6. Recommendation and next steps

Step 5: Use data responsibly and finish a capstone

Check whether your data represents the people the model affects, whether a feature acts as a stand-in for a sensitive attribute, and how errors would harm someone. For the capstone, pick a question and a dataset you find interesting (for example public data from your city), and go through the whole workflow: clean, explore, test a hypothesis, build and tune a model, and write the report. Publish the code and README on GitHub.

Capstone checklist
[ ] A clear question and success measure
[ ] Raw data kept untouched, cleaning scripted
[ ] EDA with at least four charts and written findings
[ ] One statistical test with an effect size
[ ] A baseline and at least two models, compared with cross-validation
[ ] Test set used once at the end
[ ] Saved pipeline and a predict function
[ ] README and a short report

FAQs

What should I learn after this course?
Good next steps are SQL for getting data, deeper machine learning (gradient boosting, time series, text), and the data engineering courses in this category, which show how to build the pipelines that deliver reliable data to your models.

Summary

Organize your project, save the whole pipeline with joblib, wrap prediction in a validated function, communicate the answer before the evidence, consider the impact of errors, and finish with a portfolio capstone.

Related tutorials

Comments

Log in or create a free account to join the discussion.

  • No comments yet. Be the first to comment.