ParticlePeter/ds-linear-regression

neue fische notebook lecture on Scikit and linear regression

★ 0Forks 0Jupyter NotebookGitHub ↗Compare

README

Linear Regression

A hands-on introduction to linear regression for data science. You will fit simple and multiple regression models with scikit-learn and statsmodels, see where linear regression breaks down, and learn how to handle categorical predictors. The notebooks alternate between worked lessons and short exercises so you can practice each idea as you go.

Learning Objectives

By the end of this repository, you should be able to:

  • Fit and interpret a simple linear regression model with scikit-learn.
  • Extend regression to several predictors and read the resulting coefficients.
  • Recognize the assumptions and limitations of linear regression.
  • Encode and interpret categorical variables in a regression model.
  • Fit an OLS model with statsmodels and read its statistical summary.

Learning Path

Work through the notebooks in order. The lessons introduce each concept, and the exercise notebooks let you practice before moving on.

File / Folder Description
1 - Simple Linear Regression (scikit-learn) Fit your first linear regression model with scikit-learn.
2 - Limitations of Linear Regression Where linear regression breaks down, and the assumptions behind it.
3 - Exercise: Simple Linear Regression Practice simple linear regression on your own.
4 - Multiple Linear Regression (scikit-learn) Model a target from several predictors at once.
5 - Exercise: Multiple Linear Regression Practice multiple linear regression on your own.
6 - Categorical Variables Encode and interpret categorical predictors in a regression.
7 - Linear Regression with statsmodels Fit an OLS model and read its statistical summary.

Additional Folders and Files

File / Folder Description
Data Datasets used across the notebooks (car prices and car seats).
Assets Figures displayed in the notebooks.
Solutions Worked solutions, added later in the course.
3D Regression Plot Standalone script that renders a 3D multiple-regression surface.
pyproject.toml Project configuration and dependencies.
uv.lock Dependency lock file.

Setup

Note

Throughout these steps, text in angle brackets like <repo-name> is a placeholder. Replace it, including the < > brackets, with your own value. For example, cd <repo-name> becomes cd ds-linear-regression.

1. Create the Repository from the Template

Click Use this template on GitHub.

When creating the repository:

  • Set yourself as the Owner
  • Choose a repository name
  • Disable Include all branches
  • Click Create repository

Important

If you are working in pairs or groups, only one person should complete this step.


2. Add Collaborators (Pairs/Groups Only)

If working with teammates:

  1. Open the repository on GitHub
  2. Go to Settings → Collaborators
  3. Add your teammates as collaborators
  4. Share the repository link with your team

Teammates should accept the invitation before continuing.


3. Clone the Repository

Copy the SSH URL from the Code button on GitHub, then run:

git clone <copied-ssh-url>

The copied SSH URL will look like [email protected]:<your-username>/<repo-name>.git.


4. Move into the Project Folder and Install Dependencies

This installs all dependencies and creates a virtual environment in .venv/.

cd <repo-name>
uv sync

5. Open the Notebooks

Note

Make sure you open VS Code from the project root so it automatically detects the environment created by uv sync.

Launch VS Code in the project root folder:

code .

Then open a notebook and select the Python environment created by uv sync as the kernel.

References & Further Reading

Contributors

ParticlePeter

Issues