Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

164
Views
Error value in simple gradient descent algorithm keeps increasing with each iteration
const gradientDescent = (dataPoints) => {
    const learningRate = 0.5
    let m=10; let c=10;
    dataPoints.forEach(valuePair => {
        const guessY = m*valuePair[0] + c
        const actualY = valuePair[1]
        const error = actualY - guessY

        const deltaM = error * valuePair[0] * learningRate
        const deltaC = error * learningRate

        m = m + deltaM
        c = c + deltaC
        console.log(` Error: ${error}\n Actual Y: ${actualY}\n Guess Y: ${guessY}\n`)
    })
}

const array = [
    [1, 100],[2, 200],[3, 300],[4, 400],[5, 500],[6, 600]
]
gradientDescent(array)

I was following a tutorial on simple linear regression, and while the person in the tutorial got the right answer, my error value just keeps on increasing with each iteration.

Anyone knows why?
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!