def estimate_beta_ridge(x, y, alpha):
    """ SGD estimate of beta by minimizing the squared error and the
        ridge penalty scale alpha. """
    beta_initial = [decimal.Decimal(random.random()) for _ in x[0]]
    return minimize_stochastic(
        partial(squared_error_ridge, alpha=alpha),
        partial(squared_error_ridge_gradient, alpha=alpha), x, y, beta_initial,
        decimal.Decimal(0.001))
def estimate_beta_ridge(x, y, alpha):
    """ SGD estimate of beta by minimizing the squared error and the
        ridge penalty scale alpha. """
    beta_initial = [decimal.Decimal(random.random()) for _ in x[0]]
    return minimize_stochastic(partial(squared_error_ridge, alpha=alpha), 
                               partial(squared_error_ridge_gradient,
                               alpha=alpha), x, y, beta_initial, 
                               decimal.Decimal(0.001))
def estimate_beta(x, y):

    # guess the initial beta
    #beta_initial = [decimal.Decimal(random.random()) for _ in x[0]]
    #return minimize_stochastic(squared_error, squared_error_gradient,
    #                           x, y, beta_initial, decimal.Decimal(0.001))
    # guess the initial beta
    beta_initial = [random.random() for _ in x[0]]
    return minimize_stochastic(squared_error, squared_error_gradient, x, y,
                               beta_initial, 0.001)
def estimate_beta(x, y):
    
    # guess the initial beta
    #beta_initial = [decimal.Decimal(random.random()) for _ in x[0]]
    #return minimize_stochastic(squared_error, squared_error_gradient,
    #                           x, y, beta_initial, decimal.Decimal(0.001))
    # guess the initial beta
    beta_initial = [random.random() for _ in x[0]]
    return minimize_stochastic(squared_error, squared_error_gradient,
                               x, y, beta_initial, 0.001)