Sachin Nath Deora

Home / Machine Learning / Cost Function

Cost Function

“It is really hard to understand human behaviour. The unpredictability of conscious of a human being, makes it difficult even for a well trained person in public relations.” – Harleen Kaur

 

 

Cost Function:

Cost function calculates squared error of our hypothesis predictions.

Cost function for linear regression:

J({ \theta  }_{ 0 },{ \theta  }_{ 1 })\quad =\quad \frac { 1 }{ 2m } \sum _{ i=1 }^{ m }{ { (h({ x }^{ i })-{ y }^{ i }) }^{ 2 } }

Where: m – no of training examples

θ – weights, constants

h(xi) – Hypothesis predictions for ith example

yi – expected output for ith example

CostFunction_LR

If our hypothesis perfectly fit the data then (h(xi)-yi) will be zero for all xi . So our cost function will be 0(zero) if we predict exact values which were expected. And it justifies because there is no error in our hypothesis since it is giving right answers all the time.

CostFunction_LR2

In this case some of our predictions are not as expected. So some of (h(xi)-yi) will be non zero, and sum of all the squared error will be some positive value. Which is correct because there are values for which our hypothesis does not predict expected values.

0 thoughts on “Cost Function”
  1. […] Cost function: […]

  2. Source July 25, 2016 on 5:02 am Reply

    Hi, of course this post is genuinely fastidious and I have learned lot of things from it about blogging. thanks.

  3. LennyYLinton September 4, 2016 on 10:45 am Reply

    Excellent website you have here but I was curious if you knew of any forums that cover the same topics talked about in this article?

    I’d really like to be a part of online community where I can get comments
    from other knowledgeable people that share the
    same interest. If you have any recommendations, please let me know.
    Bless you!

    • Sachin Deora November 30, 2016 on 10:59 am Reply

      Hi,
      Reddit has some interesting forums. You can also use Coursera, its course discussions are very good.

  4. LuGWindley September 20, 2016 on 3:43 pm Reply

    I’m extremely impressed together with your writing skills along with using the layout on your weblog.

    Is this a paid theme or did you modify it yourself? Either way continue the nice quality
    writing, it can be rare to discover a great blog similar to this one nowadays.

  5. SoonXHarkins September 22, 2016 on 2:37 pm Reply

    I’m delighted to uncover this site. I need to to thanks for ones time only for this wonderful read!!
    I definitely savored every a part of it and that i do you have saved to fav to see new stuff on your website.

  6. HoaJMoisey September 24, 2016 on 7:16 am Reply

    Its like you read my mind! You seem to know so
    much about this, like you wrote the book in it or something.
    I think that you could do with a few pics to drive the
    message home a little bit, but instead of that, this is magnificent blog.
    A fantastic read. I will definitely be back.

  7. AshleyYAmiri September 25, 2016 on 7:05 pm Reply

    They are genuinely wonderful ideas in on the subject of blogging.
    You may have touched some good factors here.
    Any way keep up wrinting.

  8. CoraleeGPupa November 16, 2016 on 12:50 pm Reply

    Now I am just going to perform my breakfast, later than having my breakfast coming over again to read more news.

  9. FabianPSagel November 16, 2016 on 3:28 pm Reply

    Oh my goodness! Impressive article dude!

    Thanks a lot, However I am experiencing difficulties with your RSS.
    I don’t know why I cannot join it. Could there be anybody getting the identical RSS issues?
    Anyone who knows the perfect solution would you like to kindly respond?
    Thanx!!

  10. AmadoMSaison November 20, 2016 on 9:16 am Reply

    Yes! Finally someone writes about blogroll.

  11. EliQParriera November 24, 2016 on 8:13 am Reply

    Spot on with this write-up, I truly believe this internet site needs quite a lot more attention. I’ll more
    likely be returning to discover more, i appreciate you the info!

  12. IrwinULingle December 2, 2016 on 7:56 pm Reply

    There is certainly definately much to know about this topic.
    I really like all of the points you made.

Leave a Reply

Your email address will not be published. Required fields are marked *

To get the latest update of me and my works