Skip to content

Instantly share code, notes, and snippets.

Avatar
🐱
Learning

DavidM davidmaamoaix

🐱
Learning
View GitHub Profile
View LinearReg2D.py
#LinearRegTechX
def cost(x,y,k,b):
return sum([(y[i]-x[i]*k+b)**2 for i in range(0,len(x))])/len(x)
def derivX(x,y,k,b):
return sum([2*(y[i]-(k*x[i]+b))*-x[i] for i in range(0,len(x))])/len(x)
def derivB(x,y,k,b):
return -sum([2*(y[i]-(k*x[i]+b)) for i in range(0,len(x))])/len(x)