手写regression

import numpy as np
def L1_Regression(data,alpha,lamda):
    n = len(data[0]) - 1
    theta = np.zeros(n)
    for times in range(100)
        for d in data:      #相当于 theta - alpha * Σ(hXi - Yi)  
            x = d[:-1]
            y = d[-1]
            g = np.dot(theta,x) - y # hXi - Yi
            theta = theta - alpha * g * x + lamda * theta   #正则化项 lamda * theta
        print times,theta
    return theta

这里是L1正则化,区别于规则方程