Linear Regression Cost Function | Machine Learning | Explained Simply

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ก.ย. 2024
  • Learn what is Linear Regression Cost Function in Machine Learning and how it is used. Linear Regression Cost function in Machine Learning is "error" representation between actual value and model predictions.
    To minimize the error, we need to minimize the Linear Regression Cost Function. Lesser the cost function, better the learning, more accurate will be the predictions.
    ------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------
    Learn what is Linear Regression here : • What is Linear Regress...
    Linear Regression Playlist : • Artificial Intelligenc...
    ------------------------------------------------------------------------------------------------------------------
    ------------------------------------------------------------------------------------------------------------------
    You will get a New Video on Machine Learning, every Sunday, if you subscribe to my channel, here : / @codinglane
    I am dedicated to help you Learn Machine Learning in a cool way !

ความคิดเห็น • 158

  • @CodingLane
    @CodingLane  4 ปีที่แล้ว +11

    If you found any value from the video, hit the red subscribe and like button 👍. I would really love your support! 🤗🤗
    👉 You will get a New Video on Machine Learning, every Sunday, if you subscribe to my channel, here : th-cam.com/channels/JFAF6IsaMkzHBDdfriY-yQ.html

  • @codingstyle9480
    @codingstyle9480 ปีที่แล้ว +5

    Dividing the cost function by 2 is not for finding the average. It is just for convenience when the squared function is differentiated, the nominator gets a 2 for multiplication factor. So to eliminate this we just put a 2 in the denominator, I suppose.

  • @serene3202
    @serene3202 2 ปีที่แล้ว +2

    Are u student of prof. Andrew Ng? Your teaching style is very much similar to him. Anyway thank you for a great video.

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว +1

      I learned ML first from him only... and really liked his teaching. Yea... and that is why my teaching style has been adapted to his. Good to know that you found my video helpful.

  • @EmoblazeXD
    @EmoblazeXD 3 ปีที่แล้ว +4

    The 2 exponent is there to eliminate negative numbers and not because of the magnitude of the data points. If anything squaring would make them even larger.

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Yes right . Making them larger won’t be a problem, because the graph of cost vs weight will remain the same way, and we will be able to reach to the local minima of that graph.
      You can try once by taking absolute value without squaring, and then try again with taking square, you will get the same accuracy and results in both cases.

  • @bmuralikrishna8054
    @bmuralikrishna8054 3 ปีที่แล้ว +5

    Hello, JP. You explained it really very well. Thank a lot.
    Just have a query... why do we apply square for our cost function. is it really necessary?

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +2

      Hi Murali, you either need to square the cost function or take modulus of it.
      What we want is positive number for the difference between actual value and predicting value.
      Otherwise we will not be able know how large is our error.
      For eg, if our error differences are 3, -4, 2. Then cost should be = (3 + 4 + 2 )/3 = 3.
      If we don’t square or take modulus of these errors then it will mislead us giving the cost function value to be = (3 - 4 + 2 )/3 = 0.33

    • @bmuralikrishna8054
      @bmuralikrishna8054 3 ปีที่แล้ว +2

      @@CodingLane thanks a lot for your quick reply. I really understood it in now in very good manner.
      I really appreciate your effort for teaching others.

  • @supriyamanna715
    @supriyamanna715 2 ปีที่แล้ว +1

    my qn is why the square is taken? modulas was okay but why sq? next, I'm not getting why again 1/2m is needed, 1/m is okay for average but again the 1/2??

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      Hi Supriya... good question... the answer of this is already given in comments below.

  • @HailayKidu
    @HailayKidu 2 ปีที่แล้ว +5

    This is my first time accessing such a video and it is a clear way of description, thank you!

    • @CodingLane
      @CodingLane  ปีที่แล้ว

      Thank you for the appreciation. Glad it helped! 🙂

  • @rasengan9743
    @rasengan9743 2 ปีที่แล้ว +6

    You got a new sub man, i didn't know this can be this simple, i really appreciate it.

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว +1

      Thank you 😇

  • @vsmemegenix3512
    @vsmemegenix3512 ปีที่แล้ว +1

    It should be y predicted - y actual

  • @AnkitKumar-ss7sx
    @AnkitKumar-ss7sx 3 ปีที่แล้ว +1

    Great explanation brother

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      Thank You Ankit !

  • @johnnynguyen7657
    @johnnynguyen7657 3 ปีที่แล้ว +3

    You sir should be a professor

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      I am just a student for now . Thank You so much ! It really means a lot to me ! I am glad my videos helped you.

  • @Jesuschrist-x4p
    @Jesuschrist-x4p หลายเดือนก่อน +1

    best explanation on cost function. Thank you for making it so simple!

  • @AaftabShaikh567
    @AaftabShaikh567 2 ปีที่แล้ว +1

    I think the formula of cost function in this video isn't right

    • @CodingLane
      @CodingLane  ปีที่แล้ว

      Hi Aaftab, it is correct. There can different cost function formulas, depending on the type of model you are creating.

  • @malihanadeem4854
    @malihanadeem4854 3 ปีที่แล้ว +2

    Can someone please explain why did we multiply by 1/2m?

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +4

      Hello Maliha, thanks for your question.
      As we are taking the sum of squared errors of all m datapoints, dividing it with (1/m) will give us the average. Thus we multiply (1/m) to get the average of squared error.
      You can choose to multiple (1/2m) or (1/m), it wont affect our model.
      But multiplying (1/2m) makes the expression mathematically simple when we are dealing with squared error.
      Hope it helps! Let me know.

    • @malihanadeem4854
      @malihanadeem4854 3 ปีที่แล้ว +1

      @@CodingLane Thank you for the response! I finally get it

    • @ahmetozel3011
      @ahmetozel3011 2 ปีที่แล้ว

      @@CodingLane worse language i have ever seen. Bro she asked 2/m. i already know why we multiply with 1/m but why 2? WHY 2 TWO

  • @bob77097
    @bob77097 3 ปีที่แล้ว +18

    Good job. Just please stop trying to force an american accent. Doesn't matter what accent you have, you are intelligent enough to explain tought concepts to everyone. Just be you

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +4

      Thank you so much ! And I am not trying to force my accent, its now natural to me 😅. I am glab that you found my videos helpful.

    • @mohamedelsabbagh5681
      @mohamedelsabbagh5681 8 หลายเดือนก่อน +2

      He is not trying,actually i enjoed his videos though I don’t like to hear indian accent-@the channel onwer u did great

  • @drelijahmikail3916
    @drelijahmikail3916 4 หลายเดือนก่อน

    why 2m specifically? There are differences of 2m points, but there are only m values.

  • @cleisonarmandomanriqueagui9176
    @cleisonarmandomanriqueagui9176 4 หลายเดือนก่อน

    cost function can be any function for those who are asking why dividing by 2 . of course the ones that makes sense and we can minimize is a function power of 2 so that's why

  • @Karthik-yy6up
    @Karthik-yy6up 3 ปีที่แล้ว +1

    I honestly don't get why you squared it, and divided it by 2m. What's the problem in just considering the summation of all distances?

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      (Y - y_hat) can be negative (when our straight line is above a point), so it will lead to wrong answer if we just sum it. So if you don’t want to square it, then take its modulus i.e, | Y - y_hat | .
      And about the 2m, i have already answered that in the comment down below. Do check that out.

    • @Karthik-yy6up
      @Karthik-yy6up 3 ปีที่แล้ว +1

      @@CodingLane Thanks for the response 😀

  • @HettyPatel
    @HettyPatel 3 ปีที่แล้ว +1

    ty

  • @muaazi13
    @muaazi13 3 ปีที่แล้ว +4

    Explained in such easy to understand language, this was my first video tutorial and I understood it pretty well.
    Thank you.

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      I am very glad to be able to help you! Your comment really means alot to me.. Thanks alot !!

  • @Murmur1131
    @Murmur1131 3 ปีที่แล้ว +3

    I love it. Greetings from Germany!

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank You so much! I am really glad you liked it !

  • @siamami9177
    @siamami9177 2 ปีที่แล้ว +1

    Great explanation, but didn't get the point of multiplying with 1/2m in case of squared or 1/m in case of absolute. Thank You

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      I have explained that in comments section below… you can have a look at it… it might help

  • @franciscogalvez4163
    @franciscogalvez4163 2 ปีที่แล้ว +1

    I think that theres an error i your cost formula, isnt (y-y^) its (y^-y).

    • @franciscogalvez4163
      @franciscogalvez4163 2 ปีที่แล้ว

      Actually in the implementation withh Python you use this (y^-y)

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      Hi Francisco, it’s appropriate.

    • @franciscogalvez4163
      @franciscogalvez4163 2 ปีที่แล้ว

      @@CodingLane Please upload more videos with other models...
      Are very helpfull

  • @ijajahmed3618
    @ijajahmed3618 3 ปีที่แล้ว +2

    go ahead

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thanks alot Ijaj. This means alot to me !!

  • @shajanreynold8545
    @shajanreynold8545 3 ปีที่แล้ว +2

    nice explanation about the cost funtion bro understood the concept

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thanks alot Shajan! This means much to me. Glad to help !

  • @nikhilsastry6631
    @nikhilsastry6631 3 ปีที่แล้ว +2

    That's great as I took a premium course from google.... I came here for revision, as I wonder if you could explain it in simpler terms.... Great explanation 👍

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank you so much!

  • @ajaykushwaha-je6mw
    @ajaykushwaha-je6mw 3 ปีที่แล้ว +1

    what is the catch behind fake accent.

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Its now kind of natural to me 😅. But i will improve to have more of an Indian accent

  • @salahokba6837
    @salahokba6837 3 ปีที่แล้ว +1

    Cool video thank U ...when you try to tune for example the PI control Gains (kp, ki) of a closed loop sys by " genetic algorithm " the cost is the same as fitness function ...and if want to suggest to me any thing can help to code this in matlab. Thanks again for the effort

  • @nitika9769
    @nitika9769 ปีที่แล้ว +1

    Your hands are pretty 😂

    • @CodingLane
      @CodingLane  ปีที่แล้ว +1

      Haha… thanks! Its the most unique compliment I have received 😁

  • @tejaspatil3978
    @tejaspatil3978 3 ปีที่แล้ว +1

    Are you from india.. your english accent is good..
    And btw video is nice..

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank You so much! Yes, I am from India

  • @theoronno7709
    @theoronno7709 ปีที่แล้ว +1

    That is a very much good explanation. thanks for your this help

  • @theforester_
    @theforester_ 2 ปีที่แล้ว +1

    really good explanation! thanks very much. greetings from brazil

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      Hi Mauricio Jean... Good to see you. Thanks for the compliment.

  • @ekleanthony7735
    @ekleanthony7735 2 ปีที่แล้ว +1

    Nice explanation dude

  • @ivelinkarageorgiev3111
    @ivelinkarageorgiev3111 ปีที่แล้ว +1

    Thanks man , that was an excellent explanation^^, keep rocking \m/

  • @rahmatulakbar6748
    @rahmatulakbar6748 2 ปีที่แล้ว +1

    Why you devide by 2

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      I have answered this in the comments below

  • @blu_silver
    @blu_silver 3 ปีที่แล้ว +1

    Thanks bro 😜👍

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank you so much ! Your comments mean something to me.

  • @KSanofficial
    @KSanofficial 2 ปีที่แล้ว +1

    Very clear explanation. Thank you for the video!

  • @AJ-vq9ym
    @AJ-vq9ym 3 ปีที่แล้ว +1

    good explanation

  • @jahnavibehara5823
    @jahnavibehara5823 2 ปีที่แล้ว +1

    thank you :)

  • @HengChamroeunboysmall
    @HengChamroeunboysmall ปีที่แล้ว +1

    The lesson from my professor(formula without demonstraton) make me sleepy all the time, but u make it look very simple problem and understandable. Thank you!

    • @CodingLane
      @CodingLane  ปีที่แล้ว

      Glad I could help 😄

  • @habibullahsarker4339
    @habibullahsarker4339 2 ปีที่แล้ว +1

    Easy to understand this video. Thanks, coding lane.

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      You’re welcome!

  • @thepythonprogrammer4338
    @thepythonprogrammer4338 3 ปีที่แล้ว +1

    Thanks mate

  • @dens3254
    @dens3254 ปีที่แล้ว

    In this example you initiated randomly a curve. But in fact, how can we initiate the first equation/curve/line?

  • @BTae9293
    @BTae9293 2 ปีที่แล้ว +1

    Thank you

  • @sumerujain3057
    @sumerujain3057 2 ปีที่แล้ว +1

    Thanks man

  • @raselkarim2731
    @raselkarim2731 3 ปีที่แล้ว +1

    Than you! Very clear explanation, never imagined this would be such easy to understand.

  • @morenomt27
    @morenomt27 3 ปีที่แล้ว +2

    WOW! Thank you for this.. I had been trying to look everywhere which simplifies the explanation of Mean Squared Error and what its purpose into few minutes and you did superb! Just in time for my research.

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Glad I could help!

  • @jeevapriya4853
    @jeevapriya4853 3 ปีที่แล้ว +1

    jz luv the way u gave the intro ..... it's quite easy to learn from ur videos

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank You so much Jeevapriya ! This really means to me !

  • @bhargavsai2449
    @bhargavsai2449 3 ปีที่แล้ว +1

    excellent

  • @imtiaziqbal3041
    @imtiaziqbal3041 9 หลายเดือนก่อน

    why divide by 2M?

  • @devanshishah532
    @devanshishah532 2 หลายเดือนก่อน

    This was such a great explanation! thank you !!!!

  • @geezgus
    @geezgus 4 หลายเดือนก่อน

    thankyou!!

  • @BigAl6405
    @BigAl6405 3 ปีที่แล้ว +1

    GOod explanation. Thanks!

  • @mohammadawwad7832
    @mohammadawwad7832 2 ปีที่แล้ว +1

    Thanks man, very good job !

  • @rockysingh2200
    @rockysingh2200 3 ปีที่แล้ว +1

    Thanks for explaining in the best possible and easy way. I was finding this very hard but after watching this video I understood it

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thanks ! I am happy that you found value from the video !

  • @jasonkhongwir1302
    @jasonkhongwir1302 4 ปีที่แล้ว +2

    great tutorial !

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thanks alot Jason !! Glad to help !!

  • @vinayakpatil5214
    @vinayakpatil5214 2 ปีที่แล้ว +1

    thanks bro explanation is superb

  • @narendrapratapsinghparmar91
    @narendrapratapsinghparmar91 8 หลายเดือนก่อน

    Thanks

  • @Tejaswi-s5b
    @Tejaswi-s5b ปีที่แล้ว

    Zesty

  • @khaledsrrr
    @khaledsrrr ปีที่แล้ว

    nice

  • @bruh-hp3hu
    @bruh-hp3hu 2 ปีที่แล้ว +1

    thank you this was perfect

  • @rahar6009
    @rahar6009 2 ปีที่แล้ว +1

    This was awesome thank you so much

  • @kevinalexis9886
    @kevinalexis9886 2 ปีที่แล้ว +1

    This really helped thanks!

  • @johans7585
    @johans7585 2 ปีที่แล้ว +1

    Thank you man! Keep it up 💪

  • @soryegetun529
    @soryegetun529 3 ปีที่แล้ว +1

    thanks soo so much mate.

  • @-alfeim2919
    @-alfeim2919 2 ปีที่แล้ว +1

    Great math explanation!

  • @987dan987
    @987dan987 3 ปีที่แล้ว +1

    Thank you for this excelent class!

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Your Welcome Daniel !

  • @cristianistrying7866
    @cristianistrying7866 3 ปีที่แล้ว +1

    Excellently explained, thanks!

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank You... I appreciate your comment!

  • @nandiniyadav5337
    @nandiniyadav5337 2 ปีที่แล้ว +1

    Very well explained. U are amazing 😊

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      Thank You so much! It's my pleasure to create content

    • @CodingLane
      @CodingLane  2 ปีที่แล้ว

      Thank You so much! It's my pleasure to create content

  • @hemantsah8567
    @hemantsah8567 3 ปีที่แล้ว +1

    Brief... Explanatory... Great....

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      Thanks a lot Hemant ! Really appreciate it !

  • @fullbridgerecrifier
    @fullbridgerecrifier 2 ปีที่แล้ว +1

    💯

  • @madhoounni
    @madhoounni 5 หลายเดือนก่อน

    You are a GEM. explaining in simple words with drawing.

  • @stephenmurphy5055
    @stephenmurphy5055 3 ปีที่แล้ว +1

    Really well explained! Thanks!

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Thank You Stephen ! My Pleasure 😇 !!

  • @mussabafridi
    @mussabafridi ปีที่แล้ว

    thank you so much dudee

  • @pujaroy7182
    @pujaroy7182 8 หลายเดือนก่อน

    He is just great

  • @Icandleii
    @Icandleii ปีที่แล้ว

    Thank you so much

  • @farhansomali1091
    @farhansomali1091 3 ปีที่แล้ว +1

    Thank you.

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว

      Your Welcome Farhan !

  • @akshayjadhav2213
    @akshayjadhav2213 3 ปีที่แล้ว +1

    cool video!!

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      Thanks Akshay !

  • @matahariramadhan
    @matahariramadhan ปีที่แล้ว

    great video, thanks

  • @abdelrahmane657
    @abdelrahmane657 ปีที่แล้ว

    Excellent

  • @MahmudulSajib-x5e
    @MahmudulSajib-x5e ปีที่แล้ว

    Hi, great lecture. Besides your lectures, which book or online course would you recommend to learn ML topics (KNN/SVM etc.) in depth?

    • @anuragpanda7058
      @anuragpanda7058 8 หลายเดือนก่อน

      did you find a book like that?

  • @kmanju6854
    @kmanju6854 2 ปีที่แล้ว

    Woow nice explanation 👏👌

  • @neturonix
    @neturonix 3 ปีที่แล้ว +1

    👍👍👍👍👍👍👍

  • @amaankhilji9810
    @amaankhilji9810 3 ปีที่แล้ว +1

    you explained better than Andrew ng honestly

    • @CodingLane
      @CodingLane  3 ปีที่แล้ว +1

      Thank you so much ! This really means a lot to me.