In this live stream, I continue my series on Machine Learning, covering Linear Regression. I demonstrate how to code linear regression with the ordinary least squares method in JavaScript, using the p5.js library.

This video is part of the third session of my ITP “Intelligence and Learning” course (

Edited videos:
Linear Regression with Ordinary Least Squares – Part 1:
Linear Regression with Ordinary Least Squares – Part 2:

17:50 – Presenting today’s topic
32:40 – Intro to Linear Regression
1:00:20 – Part 2 of Linear Regression

To support this channel:
Coding Train Merchandise:

Send me your questions and coding challenges!:

The Coding Train website:

Links discussed in this video:
Session 3 of Intelligence and Learning:
Nature of Code:
kwichmann’s Linear Regression Diagnostics:
Linear Regression on Wikipedia:
My video on the p5.js “map” function:
My Minesweeper Coding Challenge:
My video of the ITP Spring Show:
The Coding Train Discord: song:

Source Code for the all Video Lessons:


For more Intelligence and Learning videos:
For an Introduction to Programming:
For my Nature of Code videos:
For More Live Streams:
For More Coding Challenges:

Help us caption & translate this video!