Module 02 · Applied project

Bike Demand Regression Lab

Use the hourly Bike Sharing dataset from Module 01 to build a one-feature linear regression model from scratch. Predict cnt from temp with NumPy, derive the gradient updates, compare the result with a simple mean baseline and explain what the model cannot capture. This is a mathematical implementation exercise, not a claim that temperature alone explains bike demand.

5 to 7 hours 12 connected lessons Python · pandas · NumPy · Matplotlib
Bike Sharing DatasetUCI Machine Learning Repository · Free dataset

Implementation plan

Build it in 6 steps

6 steps
  1. 01
    Load the exact hour.csv file used in Module 01, sort by dteday and hr, and record the local file name, column names, missing-value counts and row count.
  2. 02
    Choose temp as the sole feature and cnt as the target. Create a chronological 80/20 train/holdout split before fitting or scaling anything.
  3. 03
    Calculate the feature mean and standard deviation on the training rows only. Apply those same values to both partitions and handle a zero standard deviation explicitly.
  4. 04
    Implement ŷ = wx + b, mean squared error and the batch gradients for w and b. Train with gradient descent and save the loss at regular intervals.
  5. 05
    Plot the training loss and the holdout observations with the fitted line. Calculate holdout MAE and RMSE, then compare them with a baseline that predicts the training target mean.
  6. 06
    Fit the same intercept-and-slope model with np.linalg.lstsq as a numerical check. Write a short report covering the result, the baseline comparison and at least two limitations.

What to submit

Deliverables

  • A reproducible Python script or notebook using NumPy for every model and gradient calculation; scikit-learn is not used.
  • A data audit that records the downloaded file identity, actual row count, missing values and selected columns.
  • A loss-curve plot and a holdout scatter plot with the fitted regression line.
  • A compact result table with holdout MAE and RMSE for the model and the training-mean baseline.
  • A short report comparing gradient descent with np.linalg.lstsq and explaining model limitations without making causal claims.

Quality gate

Before you finish

  • dataThe chronological split happens before scaling; the holdout rows are not used to calculate preprocessing statistics.
  • mathThe implemented gradients match the stated MSE derivatives and the loss decreases during training.
  • evaluationModel and baseline metrics are calculated on exactly the same holdout rows.
  • reproducibilityThe script records its inputs and random seed where applicable, and regenerates its plots and metrics.

Follow the module

Lessons for this project

12 lessons
  1. 02.01 Functions, Graphs & ML NotationRead the notation that appears in model equations: inputs, outputs, parameters, sums and the basic role of logarithms.
  2. 02.02 Vectors & Vector GeometryRepresent multiple measurements as a vector and reason about its direction, magnitude and distance from another vector.
  3. 02.03 Dot Products & SimilarityUnderstand the dot product as both a weighted sum and a measure of alignment between two vectors.
  4. 02.04 Matrices & Linear TransformationsTreat a matrix as a structured collection of numbers and as a transformation that maps input vectors to output vectors.
  5. 02.05 Linear Systems, Span & Least SquaresUnderstand how linear equations describe constraints, when a system can be solved exactly and how least squares handles noisy data.
  6. 02.06 Derivatives & Rates of ChangeUnderstand a derivative as the local rate of change and use basic differentiation rules to reason about how a function responds to its input.
  7. 02.07 Partial Derivatives, Gradients & Chain RuleExtend derivatives to functions with multiple inputs and understand the gradient as the direction in which a function increases most quickly.
  8. 02.08 Probability & Conditional ProbabilityRepresent uncertainty with events and probabilities, then update a probability when information about an event is known.
  9. 02.09 Random Variables & DistributionsUnderstand random variables as numeric outcomes and distributions as descriptions of how probability is assigned across possible values.
  10. 02.10 Expectation, Variance & CovarianceSummarize a distribution with its expected value and spread, then describe how two variables move together.
  11. 02.11 Loss Functions & Gradient DescentDefine an objective that measures prediction error and follow its gradient to update model parameters iteratively.
  12. 02.12 Linear Regression: Put the Math TogetherConnect a feature matrix, a parameter vector, squared error and gradient descent in one small linear-regression implementation.

How to assess your work

Project rubric

Mathematical correctness

Pass

Prediction, MSE and both parameter gradients are implemented correctly.

Strong

A finite-difference check verifies the gradients and the least-squares result is used as an independent check.

Evaluation discipline

Pass

A chronological holdout is kept separate from training and scaling.

Strong

The baseline is calculated only from training targets and compared on the exact same holdout rows.

Interpretation

Pass

The report explains the fitted relationship and gives at least two limitations.

Strong

It distinguishes association from causation and discusses omitted features, time patterns and the limitations of a straight line.

Reproducibility

Pass

The analysis can be run again with clear setup and input-file instructions.

Strong

Input identity, parameters and output locations are recorded, and all reported values regenerate from the script.

Where this leads: Classical Machine Learning: the next module expands beyond one-feature linear regression into a structured model-training and evaluation workflow.

Quick find

Search Michi

Type to search every stage, section, unit, topic and resource.

Enter opens the first result Esc closes

Reference

Keyboard shortcuts

n
Continue to the first unit not passed
j / k
Next / previous unit
1 2 3
Toggle learned, practised, passed
/
Open search
?
Show this help
Esc
Close open panels