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...

Комментарии • 69

  • @haciendadad
    @haciendadad 5 лет назад +7

    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!!

  • @oussamasingle7815
    @oussamasingle7815 7 лет назад +21

    learning while having some fun is great , you are my favorite instructor

  • @najibsaad5765
    @najibsaad5765 7 лет назад +1

    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.

  • @liminal18
    @liminal18 7 лет назад +3

    That was an amazing demostration of linear regression.

  • @pallaviray550
    @pallaviray550 2 года назад +1

    this makes formula and maths seem so much fun!

  • @jordanscarrott3749
    @jordanscarrott3749 7 лет назад +4

    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

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +2

      Thanks for your support!! I'm amazed, I remember asking people to help get me to 5k subscribers.

  • @tanajacampbell6035
    @tanajacampbell6035 2 года назад

    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!

  • @davidbarrar5968
    @davidbarrar5968 5 лет назад +1

    Best coding tutorial (and math lesson) ever!

  • @8eck
    @8eck 4 года назад +1

    Now i know that there is a method to see whether linear regression is good for some data or it's not. Thank you!

  • @Mezklador
    @Mezklador 7 лет назад +1

    Bravo for this really nice realtime linear regression demo!

  • @hamadaparis3556
    @hamadaparis3556 3 года назад

    This is thorough explanation thank you so much

  • @sacheras3
    @sacheras3 7 лет назад

    amazing explication, the best of many videos I've seen about LR. Thanks

  • @josee248
    @josee248 7 лет назад

    part 2 didn't take long. Awesome thanks

  • @girishlc
    @girishlc 4 года назад +1

    I really like your videos of teaching, thank you very much .
    Also can u please explain about RLS (Recursive Linear Regression)

  • @abhinavbanisetti956
    @abhinavbanisetti956 3 года назад

    One of the assumptions of linear regression is to have the residuals scattered randomly....now I know why!

  • @pete_thompson
    @pete_thompson Год назад

    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!

  • @chiruvlogss
    @chiruvlogss 5 лет назад

    Learning while having some fun is great , you are COOL

  • @ChrisMills333
    @ChrisMills333 7 лет назад +1

    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.

  • @habiburrehman7482
    @habiburrehman7482 4 года назад

    Maths is sometimes boring but this dude didn't bore me at all.

  • @amitbansode
    @amitbansode 6 лет назад

    example is awesome , thanks for your knowledge sharing

  • @0xccd
    @0xccd 7 лет назад +3

    you are the best!!! all your videos are pretty awesome

  • @RupertBruce
    @RupertBruce Год назад

    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 🤓

  • @jhonsilvaale7784
    @jhonsilvaale7784 4 года назад

    awesome!

  • @user-oj3gb8nh2q
    @user-oj3gb8nh2q 7 лет назад +1

    great video. very interesting

  • @nfluka
    @nfluka 7 лет назад +1

    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.

  • @bretthaupt1019
    @bretthaupt1019 7 лет назад

    Kelvin is the only true temperature. anyway keep up the educational videos

  • @peterfarrell66
    @peterfarrell66 6 лет назад +2

    9:55 "Eh, you can look it up." :-)

  • @bronka42
    @bronka42 6 лет назад

    yeah! atletic coding!

  • @nikhil199029
    @nikhil199029 6 лет назад

    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?

  • @amdreallyfast
    @amdreallyfast 6 лет назад

    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?

    • @afonsorafael2728
      @afonsorafael2728 6 лет назад

      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

    • @amdreallyfast
      @amdreallyfast 6 лет назад

      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.

    • @RahulSahu1996
      @RahulSahu1996 5 лет назад

      @@amdreallyfast Here is an online editor. editor.p5js.org/

  • @amanankesh6112
    @amanankesh6112 5 лет назад +1

    Who is that idiot disliked this video?
    Really nice video ....

  • @normaltrader7136
    @normaltrader7136 7 лет назад

    hey can u plz upload the ringtone of coding train ...I loved it ..plz share the download link
    as always u are the best !!

  • @PhilBoswell
    @PhilBoswell 7 лет назад

    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…

  • @blykgod
    @blykgod 6 лет назад

    Sorry but what is the advantage of mapping to 0,1 and then back to original?

  • @theancientone55
    @theancientone55 7 лет назад +1

    You forgot to put in the link for the "map" function... Sorry, Dan...

  • @VMan12311
    @VMan12311 3 года назад

    you're the greatest person that ever lived... actually jk, 2nd greatest because I love my mom

  • @liminal18
    @liminal18 7 лет назад

    you could have just done xsum = data.reduce((acc, cur) => acc + cur.x, 0)

  • @timsouthorn6478
    @timsouthorn6478 7 лет назад

    Subscribed for "math-sss"

  • @lucasmontec
    @lucasmontec 7 лет назад

    Is is possible to create a detection algorithm that says if linear regression is bad for a data set?

    • @andersgrobstokdalen8370
      @andersgrobstokdalen8370 7 лет назад

      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.

  • @Dgsrgv
    @Dgsrgv 6 лет назад

    what happens when at the beginning you mousepress the same spot. i wonder what that look like

  • @mario-vy6iw
    @mario-vy6iw Год назад

    Is there a 3.1. Linear Regression video? I see 3.2, 3.3, 3.4, 3.5, no 3.1 Thanks

    • @TheCodingTrain
      @TheCodingTrain  Год назад +1

      Here's 3.1 and the full playlist ruclips.net/video/LvIa0-ZKCrc/видео.html

    • @mario-vy6iw
      @mario-vy6iw Год назад

      @@TheCodingTrain Thanks. (I was looking for 3.1 Linear Regression)

  • @CarlosDaniel-od7bx
    @CarlosDaniel-od7bx 4 года назад +1

    Hey, Dan. My code worked without using any map function, but I can't explain why haha

  • @alonattar3836
    @alonattar3836 7 лет назад +2

    with which program launguge you write this code?

  • @lucaslopesf
    @lucaslopesf 7 лет назад

    15:23 I notice what you did here haha

  • @sachithradilshan9673
    @sachithradilshan9673 5 лет назад

    why x and y values map,i could not understand

  • @theancientone55
    @theancientone55 7 лет назад +1

    You also forgot the link for kwichmann GitHub site...

    • @TheCodingTrain
      @TheCodingTrain  7 лет назад +2

      And thank you AGAIN!

    • @mathblank
      @mathblank 7 лет назад

      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.

  • @gavart4509
    @gavart4509 7 лет назад

    Code liero
    I'd like to see that
    It'd be a challenge

  • @kamalnayan9157
    @kamalnayan9157 6 лет назад +3

    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

  • @bablushaw6856
    @bablushaw6856 5 лет назад

    I had to 1st turn my adblocker off then watched this video.