Distributions
This page documents the distributions module.
ordboost.distributions
Predictive probability distributions for discrete ordinal outcomes.
ContinuousPredictiveDistribution
Bases: PredictiveDistribution
Encapsulates a continuous predictive Cumulative Distribution Function (CDF).
Provides vectorized utilities for computing expected continuous values, medians, percent point functions (quantiles/PPF), central prediction intervals, and continuous CDF probabilities across samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_y
|
ndarray
|
1D float array of shape (n_grid_points,) representing continuous physical target grid values in strictly ascending order. |
required |
grid_cdf
|
ndarray
|
2D float array of shape (n_samples, n_grid_points) containing evaluated cumulative probabilities across grid points. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
grid_y |
ndarray
|
1D float array containing grid values. |
grid_cdf |
ndarray
|
2D float array containing cumulative probabilities bounded in [0.0, 1.0]. |
Methods:
| Name | Description |
|---|---|
mean |
Calculate expected continuous values via numerical integration. |
ppf |
Calculate percent point function (inverse CDF / quantiles). |
cdf |
Evaluate continuous CDF probability P(Y <= y) at physical value y. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ordboost/distributions.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
cdf(y)
Evaluate continuous CDF probability P(Y <= y) at physical value(s) y.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
float | ArrayLike
|
If a scalar float, evaluates P(Y <= y) at y for all samples. If a 1D array of shape (n_samples,), evaluates P(Y_i <= y_i) sample-wise for each corresponding sample i. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
1D array of shape (n_samples,) containing evaluated probabilities. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If y is an array and not of shape (n_samples,). If y is not a scalar or a 1D array. |
Source code in ordboost/distributions.py
mean()
Calculate expected continuous values via numerical integration.
Returns:
| Type | Description |
|---|---|
ndarray
|
1D array of shape (n_samples,) containing expected physical values. |
Source code in ordboost/distributions.py
ppf(q)
Calculate continuous interpolated values at quantile level q.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
float | ArrayLike
|
Quantile level(s) strictly in the range [0.0, 1.0]. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
If |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any quantile in |
Source code in ordboost/distributions.py
DiscretePredictiveDistribution
Bases: PredictiveDistribution
Encapsulates a discrete Probability Mass Function (PMF) matrix.
Provides vectorized utilities for computing cumulative distribution functions (CDF), percent point functions (quantiles/PPF), expected values, medians, and prediction intervals across samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pmf
|
ndarray
|
A 2D float array of shape (n_samples, n_classes) representing the predicted probability for each discrete target class. Values along each row must sum to 1.0. |
required |
classes
|
ndarray
|
A 1D array of shape (n_classes,) representing the physical ordinal class labels in strictly ascending order. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
pmf |
ndarray
|
A 2D float array of shape (n_samples, n_classes) containing predicted class probabilities. |
classes |
ndarray
|
A 1D array of shape (n_classes,) containing the ordinal class labels. |
cdf |
ndarray
|
A 2D float array of shape (n_samples, n_classes) containing cumulative
probabilities computed from |
Methods:
| Name | Description |
|---|---|
mean |
Calculate the expected value for each sample. |
ppf |
Calculate the percent point function (inverse CDF / quantiles). |
median |
Calculate the 50th percentile prediction for each sample. |
interval |
Calculate central prediction bounds for a given significance level. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ordboost/distributions.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
cdf
property
Compute the Cumulative Distribution Function (CDF) array.
Returns:
| Type | Description |
|---|---|
ndarray
|
2D array of shape (n_samples, n_classes) containing cumulative probabilities. |
mean()
Calculate the expected value (mean) for each sample.
Returns:
| Type | Description |
|---|---|
ndarray
|
1D array of shape (n_samples,) representing expected values in physical class units. |
Source code in ordboost/distributions.py
ppf(q)
Percent Point Function (inverse CDF / quantile calculation).
Maps quantile probabilities back to discrete physical class levels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
q
|
float | ndarray
|
Quantile level(s) in the range [0.0, 1.0]. Can be a single scalar or an array of quantiles. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
If |
Raises:
| Type | Description |
|---|---|
ValueError
|
If any quantile in |
Source code in ordboost/distributions.py
PredictiveDistribution
Bases: ABC
Abstract base class for all predictive probability distributions.
Defines a unified interface for extracting point estimates, quantiles, prediction intervals, and cumulative probabilities regardless of whether the distribution is discrete or continuous.
Methods:
| Name | Description |
|---|---|
mean |
Calculate expected values across samples. |
median |
Calculate 50th percentile predictions across samples. |
ppf |
Calculate percent point function (inverse CDF / quantiles). |
interval |
Calculate central prediction bounds for a given significance level. |
Source code in ordboost/distributions.py
interval(alpha=0.1)
Calculate central prediction bounds for a given significance level.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
alpha
|
float
|
Significance level (e.g., alpha=0.10 yields a 90% central interval). |
0.10
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
Tuple of (lower_bounds, upper_bounds), each as a 1D array. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in ordboost/distributions.py
mean()
abstractmethod
median()
Calculate the 50th percentile (median) prediction for each sample.
Returns:
| Type | Description |
|---|---|
ndarray
|
1D array of shape (n_samples,) containing median predictions. |