GAMLS#
- class sknormod.gam.GAMLS(mu_formula='y ~ 1', sigma_formula='~ 1')#
Generalized Additive Model with Location-Scale (GAMLSS) implemented using the
mgcv
package 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.
Examples
>>> from sknormod.gam import GAMLS >>> import numpy as np >>> X = np.arange(100).reshape(100, 1) >>> y = np.random.normal(0, 1, 100) >>> gamls = GAMLS(mu_formula="y ~ 1", sigma_formula="~ 1") >>> gamls.fit(X, y) GAMLS()
- Attributes:
- fitted_model_R object
The fitted GAMLSS model obtained from R’s
mgcv
package.- _logpdffunction
Function for calculating the logarithm of the probability density function (PDF) of the distribution.
- _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.
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 the percentiles of the distribution.
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 the target values to percentiles.
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
MetadataRequest
encapsulating 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 the percentiles of the distribution.
- Parameters:
- Xarray-like or sparse matrix of shape (n_samples, n_features)
The input samples.
- parray-like of shape (n_percentiles,)
The percentiles to predict.
- Returns:
- percentileslist of floats
The predicted percentiles.
- 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, 2)
Predicted distribution parameters where each row represents [mu, sigma].
- 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 the target values to percentiles.
- transform_to_z(X, y)#
Transform the target values to z-scores.