0
    import pandas as pd
    from pygam import LogisticGAM
    from sklearn.datasets import load_breast_cancer

    #load the breast cancer data set
    data = load_breast_cancer()
    # keep first 6 features only
    df = pd.DataFrame(data.data, columns=data.feature_names) [['mean radius', 'mean texture', 'mean perimeter', 'mean area', 'mean smoothness', 'mean compactness']]
    target_df = pd.Series(data.target)
    df.describe()
    X = df[['mean radius', 'mean texture', 'mean perimeter', 'mean area', 'mean smoothness', 'mean compactness']]
    #Fit a model with the default parameters
    gam = LogisticGAM().fit(X,y)
    gam.accuracy(X,y)


    XX = generate_X_grid(gam)

Error:

NameError
<ipython-input-17-xxx 
 ---> 1 XX = generate_X_grid(gam)
NameError: name 'generate_X_grid' is not defined 
Bitcoin M
  • 1,206
  • 8
  • 24
  • You need to either `import` or `def`ine `generate_X_grid` – Tomerikoo Jul 13 '19 at 23:50
  • You can do as follows: `gam = GAM().fit(X, y) gam.generate_X_grid(term=...)` It looks like you are referencing some out-of-date usage. Also visit reference- Here is the complete example of your expected task: https://codeburst.io/pygam-getting-started-with-generalized-additive-models-in-python-457df5b4705f – Muhammad Usman Bashir Nov 11 '19 at 13:23
  • Thanks! This is working for me. – Lily Wei Dec 10 '19 at 19:23

0 Answers0