def estimate_beta_ridge(x, y, alpha):
 beta_initial = [random.random() for x_i in x[0]]
 return minimize_stochastic(partial(squared_error_ridge, alpha=alpha), partial(squared_error_ridge_gradient, alpha=alpha), x, y, beta_initial, 0.001)

def estimate_beta_ridge ( x , y , alpha ) : beta_initial = [ random . random ( ) for x_i in x [ 0 ] ] return minimize_stochastic ( partial ( squared_error_ridge , alpha = alpha ) , partial ( squared_error_ridge_gradient , alpha = alpha ) , x , y , beta_initial , 0.001 )
use gradient descent to fit a ridge regression with penalty alpha .