This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#use <conio> | |
#use <string> | |
/* | |
Walmart version of a regex matcher. Only supports the following regex: | |
- character class (e.g. '[a-zA-Z0-9_]', '[^a-z]', '[531-]') | |
- choice '|' | |
- match any '.' | |
- match one or more '+' | |
- match any times '*' |