convexity_#

pygam.penalties.convexity_(n, coef, convex=True)[source]#

Builds a penalty matrix for P-Splines with continuous features. Penalizes violation of convexity in the feature function.

Parameters:
nint

number of splines

coefarray-like

coefficients of the feature function

convexbool, default: True

whether to enforce convex, or concave functions

Returns:
penalty matrixsparse csc matrix of shape (n,n)