bucky.util.spline_smooth
#
Method of smoothing data w/ splines. Based of a GAM from mgcv with a cr() basis.
Module Contents#
Classes#
Class for idenity link functions. |
|
Class for log link functions. |
Functions#
|
Penalized iterativly reweighted least squares. |
|
Apply constraints to the design matrix. |
|
Return base functions for the spline basis. |
|
Python version of the R lib mgcv function cr(). |
|
Find the lower bound for the knots. |
|
Builds an unconstrained cubic regression spline design matrix. |
|
Returns mapping of natural cubic spline values to 2nd derivatives. |
|
Perform fit of natural cubic splines to the vector y, return the smoothed y. |
|
Calculate exact soln for batched linear regression and return either weights or fitted values. |
|
WIP Fit a logistic function to batched y. |
|
Add I to a batch of matrices (...,M,M) until all are positive-definite (and cholesky-able). |
|
Return the number of uniq values along a given axis. |
|
Calculate the exact soln to the ridge regression of the weights for basis x that fit data y. |
|
Calculate the exact soln to the ridge regression of the weights for basis x that fit batched data y. |
Attributes#
- bucky.util.spline_smooth.PIRLS(x, y, alp, pen, tol=1e-07, dist='g', max_it=10000, w=None, gamma=1.0, tqdm_label='PIRLS', fixed_lam=False, ret_beta=False, bootstrap=False)[source]#
Penalized iterativly reweighted least squares.
- bucky.util.spline_smooth._absorb_constraints(design_matrix, constraints, pen=None)[source]#
Apply constraints to the design matrix.
- bucky.util.spline_smooth._compute_base_functions(x, knots)[source]#
Return base functions for the spline basis.
- bucky.util.spline_smooth._cr(x, df, center=True)[source]#
Python version of the R lib mgcv function cr().
- bucky.util.spline_smooth._find_knots_lower_bounds(x, knots)[source]#
Find the lower bound for the knots.
- bucky.util.spline_smooth._get_free_crs_dmatrix(x, knots)[source]#
Builds an unconstrained cubic regression spline design matrix.
- bucky.util.spline_smooth._get_natural_f(knots)[source]#
Returns mapping of natural cubic spline values to 2nd derivatives.
- bucky.util.spline_smooth.fit(y, x=None, df=10, alp=2.0, dist='g', standardize=True, w=None, gamma=1.4, tol=1e-07, clip=(None, None), label='fit', bootstrap=False)[source]#
Perform fit of natural cubic splines to the vector y, return the smoothed y.
- bucky.util.spline_smooth.lin_reg(y, x=None, alp=0.0, quad=False, return_fit=True)[source]#
Calculate exact soln for batched linear regression and return either weights or fitted values.
- bucky.util.spline_smooth.logistic_fit(y, x_out, x=None, alp=0.6, t0_max=200, L=None)[source]#
WIP Fit a logistic function to batched y.
- bucky.util.spline_smooth.make_DP(x)[source]#
Add I to a batch of matrices (…,M,M) until all are positive-definite (and cholesky-able).
- bucky.util.spline_smooth.nunique(arr, axis=- 1)[source]#
Return the number of uniq values along a given axis.