3.3: Linear Regression with Ordinary Least Squares Part 2 - Intelligence and Learning
HTML-код
- Опубликовано: 10 окт 2024
- In this video, part of my series on "Machine Learning", I explain how to perform Linear Regression for a 2D dataset using the Ordinary Least Squares method. This is Part 2 where I demonstrate how to code the algorithm in JavaScript, using the p5.js library
Link to Part 1: • 3.2: Linear Regression...
This video is part of session 3 of my Spring 2017 ITP "Intelligence and Learning" course (github.com/shi...)
Support this channel on Patreon: / codingtrain
To buy Coding Train merchandise: www.designbyhu...
Send me your questions and coding challenges!: github.com/Cod...
Contact:
Twitter: / shiffman
The Coding Train website: thecodingtrain....
Links discussed in this video:
Session 3 of Intelligence and Learning: github.com/shi...
Nature of Code: natureofcode.com/
kwichmann's Linear Regression Diagnostics: kwichmann.gith...
Linear Regression on Wikipedia: en.wikipedia.o...
Anscombe's quartet on Wikipedia: en.wikipedia.o...
My video on the p5.js map() function: • 2.5: The map() Functio...
Source Code for the all Video Lessons: github.com/Cod...
p5.js: p5js.org/
Processing: processing.org
For More Coding Challenges: • Coding Challenges
For More Intelligence and Learning: • Intelligence and Learning
Help us caption & translate this video!
amara.org/v/72nc/
📄 Code of Conduct: github.com/Cod...
You really make these topics interesting! Some other Vloggers can put me to sleep, but I seem to enjoy yours so much it is like reading a good book, I can't wait till the next video and that is saying a lot for someone who doesn't like to read due to dyslexia. I am thankful for finding your videos!!
learning while having some fun is great , you are my favorite instructor
You are one of the few RUclipsrs who work hard for high-quality content, and has a really good preforming personality as well as charisma. I only wanted to say that you are the person who should has viral videos.
That's very nice to hear, thank you!
That was an amazing demostration of linear regression.
this makes formula and maths seem so much fun!
I'm so happy to see this channel getting 250k+ subs. I hate to be that guy, but I subbed when it was called Daniel Shiffman and had about 13k. This is some quality content thats made available here, keep it up
Thanks for your support!! I'm amazed, I remember asking people to help get me to 5k subscribers.
Calculating the correlation coefficient (r), and even better, r-squared are the best ways of determining if linear least squares is the best fit...the closer the values are to 1, the better the fit!
Best coding tutorial (and math lesson) ever!
Now i know that there is a method to see whether linear regression is good for some data or it's not. Thank you!
Bravo for this really nice realtime linear regression demo!
Thank you!
This is thorough explanation thank you so much
amazing explication, the best of many videos I've seen about LR. Thanks
part 2 didn't take long. Awesome thanks
I really like your videos of teaching, thank you very much .
Also can u please explain about RLS (Recursive Linear Regression)
One of the assumptions of linear regression is to have the residuals scattered randomly....now I know why!
Because the graphing issue happens all the time - mapping a cartesian coordinate system to the display - I solved it by create a class I called "Display Mapper". You create an instance of the class by feeding it the coordinate range and the display range. (In this case (0-1, 0-1) for x and y against (0-400, 400-0) for the display. I added a couple of functions in the class that are coordsToDisplay and displayToCoords. You just feed in a vector and get back a vector, but it is mapped in one direction or the other. (example: let v = cMap.coordsToDisplay(createVector(0.5, 0.5)) returns a vector v.x = 200, v.y=200. NOTE, you can also then put things like a buffer around the edge of the canvas to make it prettier. Happy Coding!
Learning while having some fun is great , you are COOL
Hey Dan, it mightve been simpler to use scale() to just flip the canvas math so its right side up like most people understand graphs.
Maths is sometimes boring but this dude didn't bore me at all.
example is awesome , thanks for your knowledge sharing
you are the best!!! all your videos are pretty awesome
Thank you!!
I've been coding for decades. Your videos are a beautiful oasis! Is there a way to 'decorate' each function with the different threads that are calling them (eg. Functions attached to setup() versus functions called by draw() or some UIEvent). To beginner coders, that entire dimension of the code is missing - by adding decorators to the functions (even comments would help!), that hidden dimension is revealed 🤓
awesome!
great video. very interesting
Thank you!
I wonder will you ever use forEach or reduce functions. Some how you always forget :)
But, as always very interesting video. To bad I've missed stream.
Kelvin is the only true temperature. anyway keep up the educational videos
9:55 "Eh, you can look it up." :-)
yeah! atletic coding!
an absolute noob here.
So using this specific formula of mean, doesn't fall under supervised learning?
because we are learning at one instant and not taking any constant feedback?
One thing I can't find in your videos is how you started your code. What program are you using, and how are you running it in your browser? My only hints are a text editor with a dark grey background and "localhost:8000/linear_regression/" in the browser address bar. That's not a lot to go one. Do you have a video on what tools to use and how to use them?
John Cox look better.. this JavaScript, and his using a library called p5. Now his specific set up, that is another story, he has a whole video about that too
Fonso Afael and which series is that? I kept looking and found p5, took a couple hours to figure out what it was and how to use it (surprisingly difficult task since most of the material was about how to use it once it was set up (generally unhelpful instruction: "use it"), not what it was and how to set it up). Then I found his video series about using p5, but have yet seem what program (s) he is using.
@@amdreallyfast Here is an online editor. editor.p5js.org/
Who is that idiot disliked this video?
Really nice video ....
hey can u plz upload the ringtone of coding train ...I loved it ..plz share the download link
as always u are the best !!
Do you have a video which shows how to set up the environment that you use? It's probably something really simple that I'm overlooking but I don't recognise the editor or how you get it to always use the :8000 sub-address. It's similar enough to Processing that I could manage to follow but different enough to confuse…
Thanks for posting this Mathieu!
Actually, I have the same question
Sorry but what is the advantage of mapping to 0,1 and then back to original?
You forgot to put in the link for the "map" function... Sorry, Dan...
Thank you for the reminder!
you're the greatest person that ever lived... actually jk, 2nd greatest because I love my mom
you could have just done xsum = data.reduce((acc, cur) => acc + cur.x, 0)
Subscribed for "math-sss"
Mission accomplished!
Is is possible to create a detection algorithm that says if linear regression is bad for a data set?
If you'r talking about simple linear regression, then kind of. But not really. Let's say you want to know if it is good for the data set:
Take a look at the regression coefficient. Is it significant enough given your desired confidence level? If yes, then return TRUE. If not, return FALSE. Or maybe set a threshold at a certain R-squared value (the percentage of the response variable variation that is explained by a linear model). But it all kind of depends on what kind of data you have. Does it look linear? And more important: Is it likely that the response variable decreases/increases at a constant rate with the x variable (predictor variable)?
TLDR: Yes, but it would have no actual value.
what happens when at the beginning you mousepress the same spot. i wonder what that look like
Is there a 3.1. Linear Regression video? I see 3.2, 3.3, 3.4, 3.5, no 3.1 Thanks
Here's 3.1 and the full playlist ruclips.net/video/LvIa0-ZKCrc/видео.html
@@TheCodingTrain Thanks. (I was looking for 3.1 Linear Regression)
Hey, Dan. My code worked without using any map function, but I can't explain why haha
with which program launguge you write this code?
thats JS -> javascript
Peter Wacker thanks u
15:23 I notice what you did here haha
why x and y values map,i could not understand
You also forgot the link for kwichmann GitHub site...
And thank you AGAIN!
It's actually in the "Links discussed in this video" section of the description. There's a lot of stuff in there, it's easy to miss.
Thank you for pointing out the missing map() function video, very helpful!
It's all added now.
Code liero
I'd like to see that
It'd be a challenge
You always inspire me.Thanks a lot for your efforts! I have converted your code into python and have used Python's Pygame module for visual demonstration...check out the video here... ruclips.net/video/c_eFjaLTBUo/видео.html
I had to 1st turn my adblocker off then watched this video.