flexcode
Submodules
Package 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)
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)
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_coefs(x_new)
- predict(x_new, n_grid)
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
- estimate_error(x_test, z_test, n_grid=1000)
Estimates CDE loss on test data
- Parameters:
x_test – A numpy matrix of covariates
z_test – A numpy matrix of z values
n_grid – Number of grid points at which to predict the
conditional density :returns: an estimate of the CDE loss :rtype: float