diff --git a/notebooks/warnings.ipynb b/notebooks/warnings.ipynb index 1db01bf..dae579f 100644 --- a/notebooks/warnings.ipynb +++ b/notebooks/warnings.ipynb @@ -20,9 +20,9 @@ "gam = LinearGAM().gridsearch(gam_X, gam_y, n_splines=np.arange(1, 6))\n", "```\n", "\n", - "Here we fit a linear Generalized Additive Model (GAM) with the indices of the learning or power curve (gam_X) and the actual curve (gam_y) to get a smoothed version of the same. Pygam will try to fit different models with different parameters using a Gridsearch algorithm, these parameters are not user defined, but chosen internally by Pygam.\n", + "Here we fit a linear Generalized Additive Model (GAM) with the indices of the learning or power curve (gam_X) and the actual curve (gam_y) to get a smoothed version of the same. Pygam will try to fit different models with different hyperparameters using a Gridsearch algorithm. These hyperparameters are not user defined, but chosen internally by Pygam.\n", "\n", - "In our code we specify \"n_splines=np.arange(1, 6)\", this means that we want to try 6 combinations of hyperparameters of which none of them are equivalent. This code produces some hyperparameter combinations that return the warning. The problem can be easily solved by simply reducing the number of combinations.\n", + "In our code we specify \"n_splines=np.arange(1, 6)\", this means that we want to try 6 combinations of hyperparameters of which none of them are equivalent (every combination is different). This code produces some hyperparameter combinations that generate the warning, but the problem can be easily solved by simply reducing the number of combinations.\n", "\n", "Let's run the example code for the adaptivesplit package with our default number of combinations: n_splines=np.arange(1, 6)\n" ] @@ -153,7 +153,7 @@ "# r2['McFadden_adj'] = 1.0 - (full_ll - self.statistics_['edof']) / null_ll\n", "\n", "# Content of the \"r2\" variable:\n", - "#OrderedDict([('explained_deviance', -inf), ('McFadden', 1.7720463545418432), ('McFadden_adj', -0.8050272941666692)])\n", + "# OrderedDict([('explained_deviance', -inf), ('McFadden', 1.7720463545418432), ('McFadden_adj', -0.8050272941666692)])\n", "\n", "# The explained deviance is -inf, while the McFadden pseudo-R2 is calculated properly. " ] @@ -165,7 +165,7 @@ "collapsed": false }, "source": [ - "As described, with 6 hyperparameter combinations we get the warning (specifically for two hyperparameter combinations). Let's test with the debugger what happens with 4 hyperparameter combination: n_splines=np.arange(1, 4):" + "As described above, with 6 hyperparameter combinations we get the warning (specifically, two warnings for two hyperparameter combinations). Let's test with the debugger what happens with 4 hyperparameter combinations: n_splines=np.arange(1, 4):" ] }, { @@ -175,7 +175,6 @@ "metadata": {}, "outputs": [], "source": [ - "\n", "# LinearGAM().gridsearch(gam_X, gam_y, n_splines=np.arange(1, 6))\n", "\"\"\"\n", "/home/giuseppe/anaconda3/envs/pytorch/lib/python3.11/site-packages/pygam/pygam.py:1150: RuntimeWarning: divide by zero encountered in scalar divide\n", @@ -197,7 +196,7 @@ "verbose=False)\n", "\"\"\"\n", "\n", - "# By reducing the number of combination the warning disappears. Regardless, the final hyperparameter for the model are the same:\n", + "# By reducing the number of hyperparameter combinations, the warning disappears. The final hyperparameters for the model are the same:\n", "# {'scale': None, 'max_iter': 100, 'tol': 0.0001, 'callbacks': [Deviance(), Diffs()], 'verbose': False, 'terms': s(0) + intercept, 'fit_intercept': True}" ] }