bucky.util.spline_smooth

Method of smoothing data w/ splines. Based of a GAM from mgcv with a cr() basis.

Module Contents

Classes

identity_link

class for idenity link functions

log_link

class for log link functions

Functions

PIRLS(x, y, alp, pen, tol=1e-07, dist='g', max_it=10000, w=None, gamma=1.0, tqdm_label='PIRLS')

Penalized iterativly reweighted least squares

_absorb_constraints(design_matrix, constraints, pen=None)

Apply constraints to the design matrix.

_compute_base_functions(x, knots)

Return base functions for the spline basis.

_cr(x, df, center=True)

Python version of the R lib mgcv function cr().

_find_knots_lower_bounds(x, knots)

Find the lower bound for the knots.

_get_free_crs_dmatrix(x, knots)

Builds an unconstrained cubic regression spline design matrix.

_get_natural_f(knots)

Returns mapping of natural cubic spline values to 2nd derivatives.

fit(y, x=None, df=10, alp=0.6, dist='g', pirls=False, standardize=True, w=None, gamma=1.0, tol=1e-07, label='fit')

Perform fit of natural cubic splines to the vector y, return the smoothed y.

nunique(arr, axis=-1)

Return the number of uniq values along a given axis.

opt_lam(x, y, alp=0.6, w=None, pen=None, min_lam=0.1, step_size=None, tol=0.001, max_it=100, gamma=1.0)

Calculate the exact soln to the ridge regression of the weights for basis x that fit data y.

ridge(x, y, alp=0.0)

Calculate the exact soln to the ridge regression of the weights for basis x that fit data y.

bucky.util.spline_smooth.dtype[source]
bucky.util.spline_smooth.memory[source]

class for idenity link functions

g(self, mu)[source]

g - id link

g_prime(self, mu)[source]

g’ - id link

mu(self, eta)[source]

mu - id link

class for log link functions

g(self, mu)[source]

g - log link

g_prime(self, mu)[source]

g’ - log link

mu(self, eta)[source]

mu - log link

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')[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=0.6, dist='g', pirls=False, standardize=True, w=None, gamma=1.0, tol=1e-07, label='fit')[source]

Perform fit of natural cubic splines to the vector y, return the smoothed y.

bucky.util.spline_smooth.nunique(arr, axis=- 1)[source]

Return the number of uniq values along a given axis.

bucky.util.spline_smooth.opt_lam(x, y, alp=0.6, w=None, pen=None, min_lam=0.1, step_size=None, tol=0.001, max_it=100, gamma=1.0)[source]

Calculate the exact soln to the ridge regression of the weights for basis x that fit data y.

bucky.util.spline_smooth.ridge(x, y, alp=0.0)[source]

Calculate the exact soln to the ridge regression of the weights for basis x that fit data y.