exponential
exponential
¶
Exponential distribution for ngboost-lightning.
Exponential
¶
Bases: Distribution
Exponential distribution with log-rate parameterization.
Internal parameter is [log_rate] where rate = exp(log_rate).
The log-link for rate avoids constrained optimization during boosting.
Note on Fisher Information
For Exponential(log_rate), the Fisher Information is [[1]]
(the identity) for every sample. This means the natural gradient
equals the ordinary gradient.
| ATTRIBUTE | DESCRIPTION |
|---|---|
n_params |
Always 1 (log_rate).
|
rate |
Rate values, shape
TYPE:
|
Construct Exponential from internal parameters.
| PARAMETER | DESCRIPTION |
|---|---|
params
|
Internal parameters, shape
TYPE:
|
Source code in ngboost_lightning/distributions/exponential.py
fit
staticmethod
¶
Estimate initial log_rate from target data.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Target values, shape
TYPE:
|
sample_weight
|
Per-sample weights, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Parameter vector |
Source code in ngboost_lightning/distributions/exponential.py
score
¶
Per-sample negative log-likelihood.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
NLL values, shape |
Source code in ngboost_lightning/distributions/exponential.py
d_score
¶
Analytical gradient of NLL w.r.t. [log_rate].
Derivation
NLL = -log(rate) + rate * y = -log_rate + exp(log_rate) * y
d(NLL)/d(log_rate) = -1 + exp(log_rate) * y = -1 + rate * y = -(1 - rate * y)
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Gradient array, shape |
Source code in ngboost_lightning/distributions/exponential.py
metric
¶
Fisher Information: [[1]] for each sample.
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
FI tensor, shape |
natural_gradient
¶
Natural gradient (fast path since FI is identity).
Since the Fisher Information is the identity matrix, the natural gradient equals the ordinary gradient.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Natural gradient, shape |
Source code in ngboost_lightning/distributions/exponential.py
mean
¶
Conditional mean (point prediction).
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Mean values |
sample
¶
Draw n samples per distribution instance.
| PARAMETER | DESCRIPTION |
|---|---|
n
|
Number of samples to draw.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Samples, shape |
Source code in ngboost_lightning/distributions/exponential.py
cdf
¶
Cumulative distribution function.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Values at which to evaluate the CDF.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
CDF values, same shape as |
Source code in ngboost_lightning/distributions/exponential.py
ppf
¶
Percent point function (inverse CDF / quantile function).
| PARAMETER | DESCRIPTION |
|---|---|
q
|
Quantiles, values in [0, 1].
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Values at the given quantiles, same shape as |
Source code in ngboost_lightning/distributions/exponential.py
logpdf
¶
Log probability density function.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Values at which to evaluate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Log-density values, same shape as |
Source code in ngboost_lightning/distributions/exponential.py
logsf
¶
Log survival function: log(1 - CDF(y)).
For Exponential(rate), logsf(y) = -rate * y.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Values at which to evaluate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Log-survival values, same shape as |
Source code in ngboost_lightning/distributions/exponential.py
crps_score
¶
Per-sample CRPS for Exponential.
Closed form (uncensored):
CRPS = y + 2*scale*exp(-y/scale) - 1.5*scale
where scale = 1/rate.
Derivation
CRPS = int_0^y F(x)^2 dx + int_y^inf (1 - F(x))^2 dx
Part 1 gives y + 2*s*exp(-y/s) - s/2*exp(-2y/s) - 1.5*s
Part 2 gives s/2*exp(-2y/s)
The exp(-2y/s) terms cancel.
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
CRPS values, shape |
Source code in ngboost_lightning/distributions/exponential.py
crps_d_score
¶
Gradient of CRPS w.r.t. [log_rate].
Derivation
Let s = 1/rate = scale.
d(CRPS)/d(s) = 2exp(-y/s)(1 + y/s) - 1.5
Chain rule to log_rate: d(s)/d(log_rate) = -s d(CRPS)/d(log_rate) = d(CRPS)/d(s) * (-s)
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Gradient array, shape |
Source code in ngboost_lightning/distributions/exponential.py
crps_metric
¶
Riemannian metric for CRPS natural gradient.
The CRPS metric in the scale parameterization is the constant
29/108 (derived analytically). Applying the Jacobian for the
log_rate parameterization ds/d(log_rate) = -s:
M_log_rate = s^2 * 29/108 = (29/108) * scale^2
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Metric tensor, shape |
Source code in ngboost_lightning/distributions/exponential.py
crps_natural_gradient
¶
Natural gradient under CRPS metric (scalar fast path).
| PARAMETER | DESCRIPTION |
|---|---|
y
|
Observed target values, shape
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[floating]
|
Natural gradient, shape |