GAMLSS#
- class sknormod.gam.GAMLSS(mu_formula='y ~ 1', sigma_formula='~ 1', nu_formula='~ 1', tau_formula='~ 1')#
Generalized Additive Models for Location, Scale, and Shape (GAMLSS) implemented using the
mgcvpackage in R.- Parameters:
- mu_formulastr, default=”y ~ 1”
The formula specifying the model for the mean response. It should be a valid formula according to R’s formula syntax.
- sigma_formulastr, default=”~ 1”
The formula specifying the model for the scale (standard deviation) of the response.
- nu_formulastr, default=”~ 1”
The formula specifying the model for the skewness of the response.
- tau_formulastr, default=”~ 1”
The formula specifying the model for the kurtosis of the response.
Examples
>>> from sknormod.gam import GAMLSS >>> import numpy as np >>> X = np.arange(100).reshape(100, 1) >>> y = np.random.normal(0, 1, 100) >>> gamlss = GAMLSS(mu_formula="y ~ 1", sigma_formula="~ 1", nu_formula="~ 1", tau_formula="~ 1") >>> gamlss.fit(X, y) GAMLSS()
- Attributes:
- fitted_model_R object
The fitted GAMLSS model obtained from R’s
mgcvpackage.- _ppffunction
Function for calculating the percent point function (inverse of the cumulative distribution function) of the distribution.
- _cdffunction
Function for calculating the cumulative distribution function (CDF) of the distribution.
- _logpdffunction
Function for calculating the logarithm of the probability density function (PDF) of the distribution.
Methods
fit(X, y)Fit the GAMLSS model.
Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
predict_distr_p(X, p)Predict percentiles for given input samples.
Predict distribution parameters for given input samples.
score(X, y)Compute the logarithmic score of the predicted distribution parameters against the true values.
set_params(**params)Set the parameters of this estimator.
transform_to_p(X, y)Transform target values to percentiles for given input samples.
transform_to_z(X, y)Transform the target values to z-scores.
- fit(X, y)#
Fit the GAMLSS model.
- Parameters:
- Xarray-like or sparse matrix of shape (n_samples, n_features)
The input samples.
- yarray-like of shape (n_samples,)
The target values.
- Returns:
- selfobject
Fitted estimator.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- predict_distr_p(X, p)#
Predict percentiles for given input samples.
- Parameters:
- Xarray-like or sparse matrix of shape (n_samples, n_features)
The input samples.
- parray-like of shape (n,)
The percentiles to predict.
- Returns:
- percentileslist of arrays
Predicted percentiles for each sample.
- predict_distr_params(X)#
Predict distribution parameters for given input samples.
- Parameters:
- Xarray-like or sparse matrix of shape (n_samples, n_features)
The input samples.
- Returns:
- paramsarray-like of shape (n_samples, k)
Predicted distribution parameters where each row represents [mu, sigma, nu, tau]. ‘k’ depends on the number of formulas specified.
- score(X, y)#
Compute the logarithmic score of the predicted distribution parameters against the true values.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- transform_to_p(X, y)#
Transform target values to percentiles for given input samples.
- Parameters:
- Xarray-like or sparse matrix of shape (n_samples, n_features)
The input samples.
- yarray-like of shape (n_samples,)
The target values.
- Returns:
- parray-like of shape (n_samples,)
The percentiles corresponding to the target values.
- transform_to_z(X, y)#
Transform the target values to z-scores.