You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -83,6 +83,7 @@ def __repr__(self): # pragma: no cover
83
83
f' pieces: {self.pieces}\n'
84
84
f' order: {self.order}\n'
85
85
f' ndim: {self.ndim}\n'
86
+
f' degrees of freedom: {self.degrees_of_freedom}\n'
86
87
f' gcv: {self.gcv}\n'
87
88
88
89
)
@@ -126,18 +127,20 @@ class CubicSmoothingSpline(ISmoothingSpline[
126
127
and less sensitive to nonuniformity of weights and xdata clumping
127
128
128
129
.. versionadded:: 1.1.0
129
-
130
-
calculate_gcv : [*Optional*] bool
131
-
If True, the Generalized Cross Validation criterion value will be calculated for the spline upon creation.
132
-
The GCV can be minimized to attempt to identify an optimal smoothing parameter, while penalizing over fitting.
133
-
Strictly speaking this involves generating splines for all smoothing parameter values across the valid domain
134
-
of the smoothing parameter [0,1] then selecting the smoothing parameter that produces the lowest GCV.
135
-
[See GCV in TEOSL (page 244 section 7.52)](https://hastie.su.domains/ElemStatLearn/printings/ESLII_print12_toc.pdf) for more information on methodology.
136
-
The simplest way to use the GCV is to setup a loop that generates a spline with your data at every step, a step size
137
-
of 0.001 is generally sufficient, and keep track of the spline that produces the lowest GCV. Setting this parameter to True,
138
-
does _not_ generate the lowest GCV, it simply generates the value for the spline with this specific smoothing parameter,
139
-
so that you may decide how to optimize it for yourself.
140
-
130
+
131
+
calculate_degrees_of_freedom : [*Optional*] bool
132
+
If True, the degrees of freedom for the spline will be calculated and set as a property on the returned
133
+
spline object. Typically the degrees of freedom may be used to calculate the Generalized Cross Validation
134
+
criterion. The GCV can be minimized to attempt to identify an optimal smoothing parameter, while penalizing
135
+
over fitting.
136
+
Strictly speaking this involves generating splines for all smoothing parameter values across the valid domain
137
+
of the smoothing parameter [0,1] then selecting the smoothing parameter that produces the lowest GCV. See
138
+
[GCV in TEOSL (page 244 section 7.52)](https://hastie.su.domains/ElemStatLearn/printings/ESLII_print12_toc.pdf)
139
+
for more information on methodology.
140
+
The simplest way to use the GCV is to setup a loop that generates a spline with your data at every step, a step
141
+
size of 0.001 is generally sufficient, and keep track of the spline that produces the lowest GCV. Setting this
142
+
parameter to True, does _not_ generate the lowest GCV, it simply sets the neccesary dependencies to use the
143
+
calculate_gcv function. You must still compute the GCV for each smoothing parameter.
141
144
142
145
"""
143
146
@@ -150,17 +153,13 @@ def __init__(self,
150
153
smooth: Optional[float] =None,
151
154
axis: int=-1,
152
155
normalizedsmooth: bool=False,
153
-
calculate_gcv: bool=False):
156
+
calculate_degrees_of_freedom: bool=False):
154
157
155
158
x, y, w, shape, axis=self._prepare_data(xdata, ydata, weights, axis)
156
-
ifcalculate_gcv:
157
-
coeffs, smooth, gcv=self._make_spline(x, y, w, smooth, shape, normalizedsmooth, calculate_gcv)
158
-
self.gcv=gcv
159
-
else:
160
-
coeffs, smooth=self._make_spline(x, y, w, smooth, shape, normalizedsmooth, calculate_gcv)
161
-
self.gcv=None
159
+
coeffs, smooth, degrees_of_freedom=self._make_spline(x, y, w, smooth, shape, normalizedsmooth, calculate_degrees_of_freedom)
0 commit comments