old_scripts/learnme_linear.py
def regression(X, Y, alist, cv_fold):
    """ 
    Training for Regression: predicts a model using two regularization parameters 
    for optimization, returning the training and cross validation errors for each. 

    """
    mse = []
    for a in alist:
        l1 = ElasticNet(alpha=a, l1_ratio=1, selection='random')
        l2 = ElasticNet(alpha=a, l1_ratio=0, selection='random')
        l1_pred = cross_val_predict(l1, X, Y, cv=cv_fold)
        l2_pred = cross_val_predict(l2, X, Y, cv=cv_fold)
        # for diagnostic curves
        l1.fit(X, Y)
        l2.fit(X, Y)
        tr1_pred = l1.predict(X)
        tr2_pred = l2.predict(X)
        # Errors, negative for 'higher better' convention
        cvl1 = -1 * metrics.mean_squared_error(Y, l1_pred)
        cvl2 = -1 * metrics.mean_squared_error(Y, l2_pred)
        trl1 = -1 * metrics.mean_squared_error(Y, tr1_pred)
        trl2 = -1 * metrics.mean_squared_error(Y, tr2_pred)
        # mean squared error for csv
        mse_i = (cvl1, trl1, cvl2, trl2)
        mse.append(mse_i)
    return mse
 
    Training for Regression: predicts a model using two regularization parameters 
    for optimization, returning the training and cross validation errors for each. 

    
Training for Regression: predicts a model using two regularization parameters
for optimization, returning the training and cross validation errors for each.
Training for Regression : predicts a model using two regularization parameters for optimization returning the training and cross validation errors for each .
def regression(X, Y, alist, cv_fold):
    mse = []
    for a in alist:
        l1 = ElasticNet(alpha=a, l1_ratio=1, selection='random')
        l2 = ElasticNet(alpha=a, l1_ratio=0, selection='random')
        l1_pred = cross_val_predict(l1, X, Y, cv=cv_fold)
        l2_pred = cross_val_predict(l2, X, Y, cv=cv_fold)
        l1.fit(X, Y)
        l2.fit(X, Y)
        tr1_pred = l1.predict(X)
        tr2_pred = l2.predict(X)
        cvl1 = -1 * metrics.mean_squared_error(Y, l1_pred)
        cvl2 = -1 * metrics.mean_squared_error(Y, l2_pred)
        trl1 = -1 * metrics.mean_squared_error(Y, tr1_pred)
        trl2 = -1 * metrics.mean_squared_error(Y, tr2_pred)
        mse_i = (cvl1, trl1, cvl2, trl2)
        mse.append(mse_i)
    return mse
def regression ( X , Y , alist , cv_fold ) : mse = [ ] for a in alist : l1 = ElasticNet ( alpha = a , l1_ratio = 1 , selection = 'random' ) l2 = ElasticNet ( alpha = a , l1_ratio = 0 , selection = 'random' ) l1_pred = cross_val_predict ( l1 , X , Y , cv = cv_fold ) l2_pred = cross_val_predict ( l2 , X , Y , cv = cv_fold ) l1 . fit ( X , Y ) l2 . fit ( X , Y ) tr1_pred = l1 . predict ( X ) tr2_pred = l2 . predict ( X ) cvl1 = - 1 * metrics . mean_squared_error ( Y , l1_pred ) cvl2 = - 1 * metrics . mean_squared_error ( Y , l2_pred ) trl1 = - 1 * metrics . mean_squared_error ( Y , tr1_pred ) trl2 = - 1 * metrics . mean_squared_error ( Y , tr2_pred ) mse_i = ( cvl1 , trl1 , cvl2 , trl2 ) mse . append ( mse_i ) return mse
Training for Regression: predicts a model using two regularization parameters
for optimization, returning the training and cross validation errors for each.
Training for Regression : predicts a model using two regularization parameters for optimization returning the training and cross validation errors for each .
""" 
    Training for Regression: predicts a model using two regularization parameters 
    for optimization, returning the training and cross validation errors for each. 

    """ # for diagnostic curves # Errors, negative for 'higher better' convention # mean squared error for csv
X
Y
alist
cv_fold