model.py
def linear_regression_model(X_tr, y_tr, X_v, y_v, X_te, y_te, **kwargs):
    '''
    This function runs the ols model on train and validate data
    with the option to include key word arguments
    '''
    # create ols model
    lm = LinearRegression(**kwargs) 
    # fit the model to train data
    lm.fit(X_tr, y_tr)
    
    # predict the popularity on the train data
    lm_pred = lm.predict(X_tr)
    # calculate the rmse on the train data
    lm_rmse = sqrt(mean_squared_error(y_tr, lm_pred))
    
    # predict the popularity on the validate data
    lm_pred_v = lm.predict(X_v)
    # calculate the rmse on the validate data
    lm_rmse_v = sqrt(mean_squared_error(y_v, lm_pred_v))
    
    # predict the popularity on the test data
    lm_pred_t = lm.predict(X_te)
    # calculate the rmse on the test data
    lm_rmse_t = sqrt(mean_squared_error(y_te, lm_pred_t))
    
    # print the train rmse
    print('RMSE for OLS using Linear Regression \n')
    print('On train data:\n', round(lm_rmse, 6), '\n')
    return lm_rmse, lm_rmse_v, lm_rmse_t

    This function runs the ols model on train and validate data
    with the option to include key word arguments
    
This function runs the ols model on train and validate data
with the option to include key word arguments
This function runs the ols model on train and validate data with the option to include key word arguments
def linear_regression_model(X_tr, y_tr, X_v, y_v, X_te, y_te, **kwargs):
    lm = LinearRegression(**kwargs) 
    lm.fit(X_tr, y_tr)
    lm_pred = lm.predict(X_tr)
    lm_rmse = sqrt(mean_squared_error(y_tr, lm_pred))
    lm_pred_v = lm.predict(X_v)
    lm_rmse_v = sqrt(mean_squared_error(y_v, lm_pred_v))
    lm_pred_t = lm.predict(X_te)
    lm_rmse_t = sqrt(mean_squared_error(y_te, lm_pred_t))
    print('RMSE for OLS using Linear Regression \n')
    print('On train data:\n', round(lm_rmse, 6), '\n')
    return lm_rmse, lm_rmse_v, lm_rmse_t
def linear_regression_model ( X_tr , y_tr , X_v , y_v , X_te , y_te , ** kwargs ) : lm = LinearRegression ( ** kwargs ) lm . fit ( X_tr , y_tr ) lm_pred = lm . predict ( X_tr ) lm_rmse = sqrt ( mean_squared_error ( y_tr , lm_pred ) ) lm_pred_v = lm . predict ( X_v ) lm_rmse_v = sqrt ( mean_squared_error ( y_v , lm_pred_v ) ) lm_pred_t = lm . predict ( X_te ) lm_rmse_t = sqrt ( mean_squared_error ( y_te , lm_pred_t ) ) print ( 'RMSE for OLS using Linear Regression \n' ) print ( 'On train data:\n' , round ( lm_rmse , 6 ) , '\n' ) return lm_rmse , lm_rmse_v , lm_rmse_t
This function runs the ols model on train and validate data
with the option to include key word arguments
This function runs the ols model on train and validate data with the option to include key word arguments
'''
    This function runs the ols model on train and validate data
    with the option to include key word arguments
    ''' # create ols model # fit the model to train data # predict the popularity on the train data # calculate the rmse on the train data # predict the popularity on the validate data # calculate the rmse on the validate data # predict the popularity on the test data # calculate the rmse on the test data # print the train rmse
X_tr
y_tr
X_v
y_v
X_te
y_te