Skip to content

Conversation

@judahrand
Copy link

@judahrand judahrand commented Apr 8, 2020

This pull request aims to resolve #247.

Minimal example:

import numpy as np
import pandas as pd
from sklearn.datasets import load_boston
from sklearn.model_selection import GridSearchCV

import pygam


def gam(x, y):
    lams = np.random.rand(10, x.shape[1])
    lams = np.exp(lams)
    linear_gam = pygam.LinearGAM(n_splines=10, max_iter=1000)
    parameters = {
        'lam': [x for x in lams]
    }
    gam_cv = GridSearchCV(linear_gam, parameters, cv=5, iid=False, return_train_score=True,
 refit=True, scoring='neg_mean_squared_error')
    gam_cv.fit(x, y)
    cv_results_df = pd.DataFrame(gam_cv.cv_results_).sort_values(by='mean_test_score', ascending=False)
    return gam_cv, cv_results_df

if __name__ == "__main__":
    X, y = load_boston(return_X_y=True)
    gam_cv, cv_results_df = gam(X, y)
    print(gam_cv)
    print(cv_results_df.head())

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #267 into master will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
+ Coverage   95.05%   95.19%   +0.13%     
==========================================
  Files          22       22              
  Lines        3178     3184       +6     
==========================================
+ Hits         3021     3031      +10     
+ Misses        157      153       -4     
Impacted Files Coverage Δ
pygam/pygam.py 94.83% <100.00%> (+0.03%) ⬆️
pygam/utils.py 87.73% <0.00%> (+0.30%) ⬆️
pygam/tests/test_GAM_methods.py 100.00% <0.00%> (+0.36%) ⬆️
pygam/tests/test_utils.py 96.50% <0.00%> (+1.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2942579...2064bea. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linearGAM with sklearn gridsearchCV

1 participant