model.py
def glm_model(X_tr, y_tr, X_v, y_v, X_te, y_te, d_str, **kwargs):
    '''
    Generalized Linear Model with a Tweedie distribution.
    This estimator can be used to model different GLMs depending 
    on the power parameter, which determines the underlying distribution.
    '''
    # create the model object
    glm = TweedieRegressor(**kwargs)

    # fit the model to our training data
    glm.fit(X_tr, y_tr)

    # predict on train
    glm_pred = glm.predict(X_tr)
    # compute root mean squared error
    glm_rmse = sqrt(mean_squared_error(y_tr, glm_pred))

    # predict on validate
    glm_pred_v = glm.predict(X_v)
    # compute root mean squared error
    glm_rmse_v = sqrt(mean_squared_error(y_v, glm_pred_v))

    # predict on test
    glm_pred_t = glm.predict(X_te)
    # compute root mean squared error
    glm_rmse_t = sqrt(mean_squared_error(y_te, glm_pred_t))
    print(f'RMSE for GLM using {d_str} Distribution \n')
    print('On train data:\n', round(glm_rmse, 6), '\n')
    # print(glm_rmse_v)
    return glm_rmse, glm_rmse_v, glm_rmse_t, glm_pred_t

    Generalized Linear Model with a Tweedie distribution.
    This estimator can be used to model different GLMs depending 
    on the power parameter, which determines the underlying distribution.
    
Generalized Linear Model with a Tweedie distribution.
This estimator can be used to model different GLMs depending
on the power parameter, which determines the underlying distribution.
Generalized Linear Model with a Tweedie distribution . This estimator can be used to model different GLMs depending on the power parameter which determines the underlying distribution .
def glm_model(X_tr, y_tr, X_v, y_v, X_te, y_te, d_str, **kwargs):
    glm = TweedieRegressor(**kwargs)
    glm.fit(X_tr, y_tr)
    glm_pred = glm.predict(X_tr)
    glm_rmse = sqrt(mean_squared_error(y_tr, glm_pred))
    glm_pred_v = glm.predict(X_v)
    glm_rmse_v = sqrt(mean_squared_error(y_v, glm_pred_v))
    glm_pred_t = glm.predict(X_te)
    glm_rmse_t = sqrt(mean_squared_error(y_te, glm_pred_t))
    print(f'RMSE for GLM using {d_str} Distribution \n')
    print('On train data:\n', round(glm_rmse, 6), '\n')
    return glm_rmse, glm_rmse_v, glm_rmse_t, glm_pred_t
def glm_model ( X_tr , y_tr , X_v , y_v , X_te , y_te , d_str , ** kwargs ) : glm = TweedieRegressor ( ** kwargs ) glm . fit ( X_tr , y_tr ) glm_pred = glm . predict ( X_tr ) glm_rmse = sqrt ( mean_squared_error ( y_tr , glm_pred ) ) glm_pred_v = glm . predict ( X_v ) glm_rmse_v = sqrt ( mean_squared_error ( y_v , glm_pred_v ) ) glm_pred_t = glm . predict ( X_te ) glm_rmse_t = sqrt ( mean_squared_error ( y_te , glm_pred_t ) ) print ( f'RMSE for GLM using {d_str} Distribution \n' ) print ( 'On train data:\n' , round ( glm_rmse , 6 ) , '\n' ) return glm_rmse , glm_rmse_v , glm_rmse_t , glm_pred_t
Generalized Linear Model with a Tweedie distribution.
Generalized Linear Model with a Tweedie distribution .
'''
    Generalized Linear Model with a Tweedie distribution.
    This estimator can be used to model different GLMs depending 
    on the power parameter, which determines the underlying distribution.
    ''' # create the model object # fit the model to our training data # predict on train # compute root mean squared error # predict on validate # compute root mean squared error # predict on test # compute root mean squared error # print(glm_rmse_v)
X_tr
y_tr
X_v
y_v
X_te
y_te
d_str