Record Class SmoothingSpline
java.lang.Object
java.lang.Record
smile.regression.gam.SmoothingSpline
- Record Components:
name- the name of the predictor variable.spline- the B-spline basis specification for this predictor.lambda- the smoothing parameter. Larger values produce smoother fits. The penalty term added to the log-likelihood islambda * beta' P beta, where P is the second-difference penalty matrix.coefficients- the fitted B-spline coefficients (after centering).center- the centering constant (mean of f(x_i) over training data), subtracted to make the smooth identifiable in the additive model.edf- the effective degrees of freedom consumed by this smooth. Computed astrace(S), where S is the smoother/hat matrix.
- All Implemented Interfaces:
Serializable
public record SmoothingSpline(String name, BSpline spline, double lambda, double[] coefficients, double center, double edf)
extends Record
implements Serializable
A penalized regression spline (P-spline) for a single predictor variable.
This is the building block of a Generalized Additive Model: each predictor
in the GAM is associated with one
SmoothingSpline that models the
non-parametric smooth contribution f_j(x_j).
The smooth function is represented as a linear combination of B-spline basis functions:
f(x) = B(x) * beta
where B(x) is a row vector of B-spline basis evaluations and
beta is the vector of coefficients estimated during model fitting.
To ensure identifiability within the additive model, the smooth is
centered: its mean over the training data is subtracted so that
sum_i f(x_i) = 0. This centering constant is stored and added
back on prediction.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSmoothingSpline(String name, BSpline spline, double lambda, double[] coefficients, double center, double edf) Creates an instance of aSmoothingSplinerecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoublecenter()Returns the value of thecenterrecord component.double[]Returns the fitted B-spline coefficients.doubleedf()Returns the effective degrees of freedom for this smooth.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.doublelambda()Returns the value of thelambdarecord component.name()Returns the name of the predictor variable.doublepredict(double x) Evaluates the smooth function at a single point.double[]predict(double[] x) Evaluates the smooth function at multiple points.spline()Returns the value of thesplinerecord component.toString()Returns a string representation of this record class.
-
Constructor Details
-
SmoothingSpline
public SmoothingSpline(String name, BSpline spline, double lambda, double[] coefficients, double center, double edf) Creates an instance of aSmoothingSplinerecord class.- Parameters:
name- the value for thenamerecord componentspline- the value for thesplinerecord componentlambda- the value for thelambdarecord componentcoefficients- the value for thecoefficientsrecord componentcenter- the value for thecenterrecord componentedf- the value for theedfrecord component
-
-
Method Details
-
predict
public double predict(double x) Evaluates the smooth function at a single point. Returnsf(x) = B(x) * coefficients - center. The centering is applied so that the smooth has zero mean over training data.- Parameters:
x- the predictor value.- Returns:
- the smooth function value (centered).
-
predict
public double[] predict(double[] x) Evaluates the smooth function at multiple points.- Parameters:
x- the predictor values.- Returns:
- the smooth function values (centered).
-
coefficients
public double[] coefficients()Returns the fitted B-spline coefficients.- Returns:
- the coefficients.
-
edf
public double edf()Returns the effective degrees of freedom for this smooth.- Returns:
- the effective degrees of freedom.
-
name
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
spline
-
lambda
-
center
-