flexcode.core
Module Contents
Classes
- class FlexCodeModel(model, max_basis, basis_system='cosine', z_min=None, z_max=None, regression_params={}, custom_model=None)[source]
Bases:
object- fit(x_train, z_train, weight=None)[source]
Fits basis function regression models.
- Parameters:
x_train – a numpy matrix of training covariates.
z_train – a numpy array of z values.
weight – (optional) a numpy array of weights.
- Returns:
None.
- Return type:
- tune(x_validation, z_validation, bump_threshold_grid=None, sharpen_grid=None, n_grid=1000)[source]
Set tuning parameters to minimize CDE loss
Sets best_basis, bump_delta, and sharpen_alpha values attributes
- Parameters:
x_validation – a numpy matrix of covariates
z_validation – a numpy array of z values
bump_threshold_grid – an array of candidate bump threshold values
sharpen_grid – an array of candidate sharpen parameter values
n_grid – integer, the number of grid points to evaluate
- Returns:
None
- Return type:
- predict(x_new, n_grid)[source]
Predict conditional density estimates on new data
- n :param x_new: A numpy matrix of covariates at which to predict
- param n_grid:
int, the number of grid points at which to
predict the conditional density :returns: A numpy matrix where each row is a conditional density estimate at the grid points :rtype: numpy matrix