Reference
In this reference you will find a detailed overview of the package API.
Reference guides are technical descriptions of the machinery and how to operate it. Reference material is information-oriented.
β DiΓ‘taxis
In other words, you come here because you want to take a very close look at the code π§
Content
Index
ConformalPrediction.available_modelsConformalPrediction.tested_atomic_modelsConformalPrediction.AdaptiveInductiveClassifierConformalPrediction.BayesRegressorConformalPrediction.CVMinMaxRegressorConformalPrediction.CVPlusRegressorConformalPrediction.ConformalIntervalConformalPrediction.ConformalProbabilisticConformalPrediction.ConformalProbabilisticSetConformalPrediction.ConformalQuantileRegressorConformalPrediction.JackknifeMinMaxRegressorConformalPrediction.JackknifePlusAbMinMaxRegressorConformalPrediction.JackknifePlusAbRegressorConformalPrediction.JackknifePlusRegressorConformalPrediction.JackknifeRegressorConformalPrediction.NaiveClassifierConformalPrediction.NaiveRegressorConformalPrediction.QuantileModelConformalPrediction.SimpleInductiveClassifierConformalPrediction.SimpleInductiveRegressorConformalPrediction.TimeSeriesRegressorEnsembleBatchConformalPrediction._aggregateConformalPrediction.absolute_errorConformalPrediction.blockbootstrapConformalPrediction.compute_intervalConformalPrediction.conformal_bayes_scoreConformalPrediction.conformal_modelConformalPrediction.emp_coverageConformalPrediction.ineffConformalPrediction.is_classificationConformalPrediction.is_classifierConformalPrediction.is_coveredConformalPrediction.is_covered_intervalConformalPrediction.is_covered_setConformalPrediction.is_regressionConformalPrediction.minus_softmaxConformalPrediction.partial_fitConformalPrediction.qminusConformalPrediction.qplusConformalPrediction.reformat_intervalConformalPrediction.reformat_mlj_predictionConformalPrediction.scoreConformalPrediction.scoreConformalPrediction.scoreConformalPrediction.set_sizeConformalPrediction.size_stratified_coverageConformalPrediction.split_dataMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.fitMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predictMLJModelInterface.predict
Public Interface
ConformalPrediction.available_models β Constant
A container listing all available methods for conformal prediction.
ConformalPrediction.tested_atomic_models β Constant
A container listing all atomic MLJ models that have been tested for use with this package.
ConformalPrediction.conformal_model β Method
conformal_model(model::Supervised; method::Union{Nothing, Symbol}=nothing, kwargs...)A simple wrapper function that turns a model::Supervised into a conformal model. It accepts an optional key argument that can be used to specify the desired method for conformal prediction as well as additinal kwargs... specific to the method.
ConformalPrediction.emp_coverage β Method
emp_coverage(yΜ, y)Computes the empirical coverage for conformal predictions yΜ.
ConformalPrediction.ineff β Function
ineff(yΜ)Computes the inefficiency (average set size) for conformal predictions yΜ.
ConformalPrediction.is_classifier β Method
is_classifier(model::Supervised)Check if the model is a classification model or a regression model
ConformalPrediction.partial_fit β Function
partial_fit(conf_model::TimeSeriesRegressorEnsembleBatch, fitresult, X, y, shift_size)For the TimeSeriesRegressorEnsembleBatch Non-conformity scores are updated by the most recent data (X,y). shift_size determines how many points in Non-conformity scores will be discarded.
ConformalPrediction.set_size β Method
set_size(yΜ)Helper function that computes the set size for conformal predictions.
ConformalPrediction.size_stratified_coverage β Method
size_stratified_coverage(yΜ, y)Computes the size-stratified coverage for conformal predictions yΜ.
ConformalPrediction.split_data β Method
split_data(conf_model::ConformalProbabilisticSet, indices::Base.OneTo{Int})Splits the data into a proper training and calibration set.
MLJModelInterface.fit β Method
MMI.fit(conf_model::AdaptiveInductiveClassifier, verbosity, X, y)For the AdaptiveInductiveClassifier nonconformity scores are computed by cumulatively summing the ranked scores of each label in descending order until reaching the true label $Y_i$:
$S_i^{\text{CAL}} = s(X_i,Y_i) = \sum_{j=1}^k \hat\mu(X_i)_{\pi_j} \ \text{where } \ Y_i=\pi_k, i \in \mathcal{D}_{\text{calibration}}$
MLJModelInterface.fit β Method
MMI.fit(conf_model::BayesRegressor, verbosity, X, y)For the BayesRegressor nonconformity scores are computed as follows:
$S_i^{\text{CAL}} = s(X_i, Y_i) = h(\hat\mu(X_i), Y_i) = - P(Y_i|X_i), \ i \in \mathcal{D}_{\text{calibration}}$ where $P(Y_i|X_i)$ denotes the posterior probability distribution of getting $Y_i$ given $X_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::CVMinMaxRegressor, verbosity, X, y)For the CVMinMaxRegressor nonconformity scores are computed in the same way as for the CVPlusRegressor. Specifically, we have,
$S_i^{\text{CV}} = s(X_i, Y_i) = h(\hat\mu_{-\mathcal{D}_{k(i)}}(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-\mathcal{D}_{k(i)}}(X_i)$ denotes the CV prediction for $X_i$. In other words, for each CV fold $k=1,...,K$ and each training instance $i=1,...,n$ the model is trained on all training data excluding the fold containing $i$. The fitted model is then used to predict out-of-sample from $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $\hat\mu_{-\mathcal{D}_{k(i)}}(X_i)$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::CVPlusRegressor, verbosity, X, y)For the CVPlusRegressor nonconformity scores are computed though cross-validation (CV) as follows,
$S_i^{\text{CV}} = s(X_i, Y_i) = h(\hat\mu_{-\mathcal{D}_{k(i)}}(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-\mathcal{D}_{k(i)}}(X_i)$ denotes the CV prediction for $X_i$. In other words, for each CV fold $k=1,...,K$ and each training instance $i=1,...,n$ the model is trained on all training data excluding the fold containing $i$. The fitted model is then used to predict out-of-sample from $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $\hat\mu_{-\mathcal{D}_{k(i)}}(X_i)$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::ConformalQuantileRegressor, verbosity, X, y)For the ConformalQuantileRegressor nonconformity scores are computed as follows:
$S_i^{\text{CAL}} = s(X_i, Y_i) = h(\hat\mu_{\alpha_{lo}}(X_i), \hat\mu_{\alpha_{hi}}(X_i) ,Y_i), \ i \in \mathcal{D}_{\text{calibration}}$
A typical choice for the heuristic function is $h(\hat\mu_{\alpha_{lo}}(X_i), \hat\mu_{\alpha_{hi}}(X_i) ,Y_i)= max\{\hat\mu_{\alpha_{low}}(X_i)-Y_i, Y_i-\hat\mu_{\alpha_{hi}}(X_i)\}$ where $\hat\mu$ denotes the model fitted on training data $\mathcal{D}_{\text{train}}` and$\alpha{lo}, \alpha{hi}`` lower and higher percentile.
MLJModelInterface.fit β Method
MMI.fit(conf_model::JackknifeMinMaxRegressor, verbosity, X, y)For the JackknifeMinMaxRegressor nonconformity scores are computed in the same way as for the JackknifeRegressor. Specifically, we have,
$S_i^{\text{LOO}} = s(X_i, Y_i) = h(\hat\mu_{-i}(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}(X_i)$ denotes the leave-one-out prediction for $X_i$. In other words, for each training instance $i=1,...,n$ the model is trained on all training data excluding $i$. The fitted model is then used to predict out-of-sample from $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $\hat\mu_{-i}(X_i)$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::JackknifePlusMinMaxAbRegressor, verbosity, X, y)For the JackknifePlusAbMinMaxRegressor nonconformity scores are as,
$S_i^{\text{J+MinMax}} = s(X_i, Y_i) = h(agg(\hat\mu_{B_{K(-i)}}(X_i)), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $agg(\hat\mu_{B_{K(-i)}}(X_i))$ denotes the aggregate predictions, typically mean or median, for each $X_i$ (with $K_{-i}$ the bootstraps not containing $X_i$). In other words, B models are trained on boostrapped sampling, the fitted models are then used to create aggregated prediction of out-of-sample $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $agg(\hat\mu_{B_{K(-i)}}(X_i))$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::JackknifePlusAbRegressor, verbosity, X, y)For the JackknifePlusAbRegressor nonconformity scores are computed as
$$ S_i^{\text{J+ab}} = s(X_i, Y_i) = h(agg(\hat\mu_{B_{K(-i)}}(X_i)), Y_i), \ i \in \mathcal{D}_{\text{train}} $$
where $agg(\hat\mu_{B_{K(-i)}}(X_i))$ denotes the aggregate predictions, typically mean or median, for each $X_i$ (with $K_{-i}$ the bootstraps not containing $X_i$). In other words, B models are trained on boostrapped sampling, the fitted models are then used to create aggregated prediction of out-of-sample $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $agg(\hat\mu_{B_{K(-i)}}(X_i))$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::JackknifePlusRegressor, verbosity, X, y)For the JackknifePlusRegressor nonconformity scores are computed in the same way as for the JackknifeRegressor. Specifically, we have,
$S_i^{\text{LOO}} = s(X_i, Y_i) = h(\hat\mu_{-i}(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}(X_i)$ denotes the leave-one-out prediction for $X_i$. In other words, for each training instance $i=1,...,n$ the model is trained on all training data excluding $i$. The fitted model is then used to predict out-of-sample from $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $\hat\mu_{-i}(X_i)$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::JackknifeRegressor, verbosity, X, y)For the JackknifeRegressor nonconformity scores are computed through a leave-one-out (LOO) procedure as follows,
$S_i^{\text{LOO}} = s(X_i, Y_i) = h(\hat\mu_{-i}(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}(X_i)$ denotes the leave-one-out prediction for $X_i$. In other words, for each training instance $i=1,...,n$ the model is trained on all training data excluding $i$. The fitted model is then used to predict out-of-sample from $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $\hat\mu_{-i}(X_i)$ and the true value $Y_i$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::NaiveClassifier, verbosity, X, y)For the NaiveClassifier nonconformity scores are computed in-sample as follows:
$S_i^{\text{IS}} = s(X_i, Y_i) = h(\hat\mu(X_i), Y_i), \ i \in \mathcal{D}_{\text{calibration}}$
A typical choice for the heuristic function is $h(\hat\mu(X_i), Y_i)=1-\hat\mu(X_i)_{Y_i}$ where $\hat\mu(X_i)_{Y_i}$ denotes the softmax output of the true class and $\hat\mu$ denotes the model fitted on training data $\mathcal{D}_{\text{train}}$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::NaiveRegressor, verbosity, X, y)For the NaiveRegressor nonconformity scores are computed in-sample as follows:
$S_i^{\text{IS}} = s(X_i, Y_i) = h(\hat\mu(X_i), Y_i), \ i \in \mathcal{D}_{\text{train}}$
A typical choice for the heuristic function is $h(\hat\mu(X_i),Y_i)=|Y_i-\hat\mu(X_i)|$ where $\hat\mu$ denotes the model fitted on training data $\mathcal{D}_{\text{train}}$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::SimpleInductiveClassifier, verbosity, X, y)For the SimpleInductiveClassifier nonconformity scores are computed as follows:
$S_i^{\text{CAL}} = s(X_i, Y_i) = h(\hat\mu(X_i), Y_i), \ i \in \mathcal{D}_{\text{calibration}}$
A typical choice for the heuristic function is $h(\hat\mu(X_i), Y_i)=1-\hat\mu(X_i)_{Y_i}$ where $\hat\mu(X_i)_{Y_i}$ denotes the softmax output of the true class and $\hat\mu$ denotes the model fitted on training data $\mathcal{D}_{\text{train}}$. The simple approach only takes the softmax probability of the true label into account.
MLJModelInterface.fit β Method
MMI.fit(conf_model::SimpleInductiveRegressor, verbosity, X, y)For the SimpleInductiveRegressor nonconformity scores are computed as follows:
$S_i^{\text{CAL}} = s(X_i, Y_i) = h(\hat\mu(X_i), Y_i), \ i \in \mathcal{D}_{\text{calibration}}$
A typical choice for the heuristic function is $h(\hat\mu(X_i),Y_i)=|Y_i-\hat\mu(X_i)|$ where $\hat\mu$ denotes the model fitted on training data $\mathcal{D}_{\text{train}}$.
MLJModelInterface.fit β Method
MMI.fit(conf_model::TimeSeriesRegressorEnsembleBatch, verbosity, X, y)For the TimeSeriesRegressorEnsembleBatch nonconformity scores are computed as
$$ S_i^{\text{J+ab}} = s(X_i, Y_i) = h(agg(\hat\mu_{B_{K(-i)}}(X_i)), Y_i), \ i \in \mathcal{D}_{\text{train}} $$
where $agg(\hat\mu_{B_{K(-i)}}(X_i))$ denotes the aggregate predictions, typically mean or median, for each $X_i$ (with $K_{-i}$ the bootstraps not containing $X_i$). In other words, B models are trained on boostrapped sampling, the fitted models are then used to create aggregated prediction of out-of-sample $X_i$. The corresponding nonconformity score is then computed by applying a heuristic uncertainty measure $h(\cdot)$ to the fitted value $agg(\hat\mu_{B_{K(-i)}}(X_i))$ and the true value $Y_i$.
MLJModelInterface.predict β Method
MMI.predict(conf_model::AdaptiveInductiveClassifier, fitresult, Xnew)For the AdaptiveInductiveClassifier prediction sets are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left\{y: s(X_{n+1},y) \le \hat{q}_{n, \alpha}^{+} \{S_i^{\text{CAL}}\} \right\}, i \in \mathcal{D}_{\text{calibration}}$
where $\mathcal{D}_{\text{calibration}}$ denotes the designated calibration data.
MLJModelInterface.predict β Method
MMI.predict(conf_model::BayesRegressor, fitresult, Xnew)For the BayesRegressor prediction sets are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left\{y: f(y|X_{n+1}) \le -\hat{q}_{ \alpha} \{S_i^{\text{CAL}}\} \right\}, \ i \in \mathcal{D}_{\text{calibration}}$
where $\mathcal{D}_{\text{calibration}}$ denotes the designated calibration data.
MLJModelInterface.predict β Method
MMI.predict(conf_model::CVMinMaxRegressor, fitresult, Xnew)For the CVMinMaxRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left[ \min_{i=1,...,n} \hat\mu_{-\mathcal{D}_{k(i)}}(X_{n+1}) - \hat{q}_{n, \alpha}^{+} \{S_i^{\text{CV}} \}, \max_{i=1,...,n} \hat\mu_{-\mathcal{D}_{k(i)}}(X_{n+1}) + \hat{q}_{n, \alpha}^{+} \{ S_i^{\text{CV}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-\mathcal{D}_{k(i)}}$ denotes the model fitted on training data with subset $\mathcal{D}_{k(i)}$ that contains the $i$ th point removed.
MLJModelInterface.predict β Method
MMI.predict(conf_model::CVPlusRegressor, fitresult, Xnew)For the CVPlusRegressor prediction intervals are computed in much same way as for the JackknifePlusRegressor. Specifically, we have,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left[ \hat{q}_{n, \alpha}^{-} \{\hat\mu_{-\mathcal{D}_{k(i)}}(X_{n+1}) - S_i^{\text{CV}} \}, \hat{q}_{n, \alpha}^{+} \{\hat\mu_{-\mathcal{D}_{k(i)}}(X_{n+1}) + S_i^{\text{CV}}\} \right] , \ i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-\mathcal{D}_{k(i)}}$ denotes the model fitted on training data with fold $\mathcal{D}_{k(i)}$ that contains the $i$ th point removed.
The JackknifePlusRegressor is a special case of the CVPlusRegressor for which $K=n$.
MLJModelInterface.predict β Method
MMI.predict(conf_model::ConformalQuantileRegressor, fitresult, Xnew)For the ConformalQuantileRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = [\hat\mu_{\alpha_{lo}}(X_{n+1}) - \hat{q}_{n, \alpha} \{S_i^{\text{CAL}} \}, \hat\mu_{\alpha_{hi}}(X_{n+1}) + \hat{q}_{n, \alpha} \{S_i^{\text{CAL}} \}], \ i \in \mathcal{D}_{\text{calibration}}$
where $\mathcal{D}_{\text{calibration}}$ denotes the designated calibration data.
MLJModelInterface.predict β Method
MMI.predict(conf_model::JackknifeMinMaxRegressor, fitresult, Xnew)For the JackknifeMinMaxRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left[ \min_{i=1,...,n} \hat\mu_{-i}(X_{n+1}) - \hat{q}_{n, \alpha}^{+} \{S_i^{\text{LOO}} \}, \max_{i=1,...,n} \hat\mu_{-i}(X_{n+1}) + \hat{q}_{n, \alpha}^{+} \{S_i^{\text{LOO}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}$ denotes the model fitted on training data with $i$th point removed. The jackknife-minmax procedure is more conservative than the JackknifePlusRegressor.
MLJModelInterface.predict β Method
MMI.predict(conf_model::JackknifePlusAbMinMaxRegressor, fitresult, Xnew)For the JackknifePlusAbMinMaxRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}^{J+MinMax}(X_{n+1}) = \left[ \min_{i=1,...,n} \hat\mu_{-i}(X_{n+1}) - \hat{q}_{n, \alpha}^{+} \{S_i^{\text{J+MinMax}} \}, \max_{i=1,...,n} \hat\mu_{-i}(X_{n+1}) + \hat{q}_{n, \alpha}^{+} \{S_i^{\text{J+MinMax}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}$ denotes the model fitted on training data with $i$th point removed. The jackknife+ab-minmax procedure is more conservative than the JackknifePlusAbRegressor.
MLJModelInterface.predict β Method
MMI.predict(conf_model::JackknifePlusAbRegressor, fitresult, Xnew)For the JackknifePlusAbRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha, B}^{J+ab}(X_{n+1}) = \left[ \hat{q}_{n, \alpha}^{-} \{\hat\mu_{agg(-i)}(X_{n+1}) - S_i^{\text{J+ab}} \}, \hat{q}_{n, \alpha}^{+} \{\hat\mu_{agg(-i)}(X_{n+1}) + S_i^{\text{J+ab}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{agg(-i)}$ denotes the aggregated models $\hat\mu_{1}, ...., \hat\mu_{B}$ fitted on bootstrapped data (B) does not include the $i$th data point. The jackknife$+$ procedure is more stable than the JackknifeRegressor.
MLJModelInterface.predict β Method
MMI.predict(conf_model::JackknifePlusRegressor, fitresult, Xnew)For the JackknifePlusRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left[ \hat{q}_{n, \alpha}^{-} \{\hat\mu_{-i}(X_{n+1}) - S_i^{\text{LOO}} \}, \hat{q}_{n, \alpha}^{+} \{\hat\mu_{-i}(X_{n+1}) + S_i^{\text{LOO}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{-i}$ denotes the model fitted on training data with $i$th point removed. The jackknife$+$ procedure is more stable than the JackknifeRegressor.
MLJModelInterface.predict β Method
MMI.predict(conf_model::JackknifeRegressor, fitresult, Xnew)For the JackknifeRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \hat\mu(X_{n+1}) \pm \hat{q}_{n, \alpha}^{+} \{S_i^{\text{LOO}}\}, \ i \in \mathcal{D}_{\text{train}}$
where $S_i^{\text{LOO}}$ denotes the nonconformity that is generated as explained in fit(conf_model::JackknifeRegressor, verbosity, X, y). The jackknife procedure addresses the overfitting issue associated with the NaiveRegressor.
MLJModelInterface.predict β Method
MMI.predict(conf_model::NaiveClassifier, fitresult, Xnew)For the NaiveClassifier prediction sets are computed as follows:
$\hat{C}_{n,\alpha}(X_{n+1}) = \left\{y: s(X_{n+1},y) \le \hat{q}_{n, \alpha}^{+} \{S_i^{\text{IS}} \} \right\}, \ i \in \mathcal{D}_{\text{train}}$
The naive approach typically produces prediction regions that undercover due to overfitting.
MLJModelInterface.predict β Method
MMI.predict(conf_model::NaiveRegressor, fitresult, Xnew)For the NaiveRegressor prediction intervals are computed as follows:
$\hat{C}_{n,\alpha}(X_{n+1}) = \hat\mu(X_{n+1}) \pm \hat{q}_{n, \alpha}^{+} \{S_i^{\text{IS}} \}, \ i \in \mathcal{D}_{\text{train}}$
The naive approach typically produces prediction regions that undercover due to overfitting.
MLJModelInterface.predict β Method
MMI.predict(conf_model::SimpleInductiveClassifier, fitresult, Xnew)For the SimpleInductiveClassifier prediction sets are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \left\{y: s(X_{n+1},y) \le \hat{q}_{n, \alpha}^{+} \{S_i^{\text{CAL}}\} \right\}, \ i \in \mathcal{D}_{\text{calibration}}$
where $\mathcal{D}_{\text{calibration}}$ denotes the designated calibration data.
MLJModelInterface.predict β Method
MMI.predict(conf_model::SimpleInductiveRegressor, fitresult, Xnew)For the SimpleInductiveRegressor prediction intervals are computed as follows,
$\hat{C}_{n,\alpha}(X_{n+1}) = \hat\mu(X_{n+1}) \pm \hat{q}_{n, \alpha}^{+} \{S_i^{\text{CAL}} \}, \ i \in \mathcal{D}_{\text{calibration}}$
where $\mathcal{D}_{\text{calibration}}$ denotes the designated calibration data.
MLJModelInterface.predict β Method
MMI.predict(conf_model::TimeSeriesRegressorEnsembleBatch, fitresult, Xnew)For the TimeSeriesRegressorEnsembleBatch prediction intervals are computed as follows,
$\hat{C}_{n,\alpha, B}^{J+ab}(X_{n+1}) = \left[ \hat{q}_{n, \alpha}^{-} \{\hat\mu_{agg(-i)}(X_{n+1}) - S_i^{\text{J+ab}} \}, \hat{q}_{n, \alpha}^{+} \{\hat\mu_{agg(-i)}(X_{n+1}) + S_i^{\text{J+ab}}\} \right] , i \in \mathcal{D}_{\text{train}}$
where $\hat\mu_{agg(-i)}$ denotes the aggregated models $\hat\mu_{1}, ...., \hat\mu_{B}$ fitted on bootstrapped data (B) does not include the $i$th data point. The jackknife$+$ procedure is more stable than the JackknifeRegressor.
Internal functions
ConformalPrediction.AdaptiveInductiveClassifier β Type
The AdaptiveInductiveClassifier is an improvement to the SimpleInductiveClassifier and the NaiveClassifier. Contrary to the NaiveClassifier it computes nonconformity scores using a designated calibration dataset like the SimpleInductiveClassifier. Contrary to the SimpleInductiveClassifier it utilizes the softmax output of all classes.
ConformalPrediction.BayesRegressor β Type
The BayesRegressor is the simplest approach to Inductive Conformalized Bayes. As explained in https://arxiv.org/abs/2107.07511, the conformal score is defined as the opposite of the probability of observing y given x : $s= -P(Y|X)$. Once the treshold $\hat{q}$ is chosen, The credible interval is then computed as the range of y values so that $C(x)= \big\{y : P(Y|X) > -\hat{q} \big}$
ConformalPrediction.CVMinMaxRegressor β Type
Constructor for CVMinMaxRegressor.
ConformalPrediction.CVPlusRegressor β Type
Constructor for CVPlusRegressor.
ConformalPrediction.ConformalInterval β Type
An abstract base type for conformal models that produce interval-valued predictions. This includes most conformal regression models.
ConformalPrediction.ConformalProbabilistic β Type
An abstract base type for conformal models that produce probabilistic predictions. This includes some conformal classifier like Venn-ABERS.
ConformalPrediction.ConformalProbabilisticSet β Type
An abstract base type for conformal models that produce set-valued probabilistic predictions. This includes most conformal classification models.
ConformalPrediction.ConformalQuantileRegressor β Type
Constructor for ConformalQuantileRegressor.
ConformalPrediction.JackknifeMinMaxRegressor β Type
Constructor for JackknifeMinMaxRegressor.
ConformalPrediction.JackknifePlusAbMinMaxRegressor β Type
Constructor for JackknifePlusAbMinMaxRegressor.
ConformalPrediction.JackknifePlusAbRegressor β Type
Constructor for JackknifePlusAbPlusRegressor.
ConformalPrediction.JackknifePlusRegressor β Type
Constructor for JackknifePlusRegressor.
ConformalPrediction.JackknifeRegressor β Type
Constructor for JackknifeRegressor.
ConformalPrediction.NaiveClassifier β Type
The NaiveClassifier is the simplest approach to Inductive Conformal Classification. Contrary to the NaiveClassifier it computes nonconformity scores using a designated training dataset.
ConformalPrediction.NaiveRegressor β Type
The NaiveRegressor for conformal prediction is the simplest approach to conformal regression.
ConformalPrediction.QuantileModel β Type
Union type for quantile models.
ConformalPrediction.SimpleInductiveClassifier β Type
The SimpleInductiveClassifier is the simplest approach to Inductive Conformal Classification. Contrary to the NaiveClassifier it computes nonconformity scores using a designated calibration dataset.
ConformalPrediction.SimpleInductiveRegressor β Type
The SimpleInductiveRegressor is the simplest approach to Inductive Conformal Regression. Contrary to the NaiveRegressor it computes nonconformity scores using a designated calibration dataset.
ConformalPrediction.TimeSeriesRegressorEnsembleBatch β Type
Constructor for TimeSeriesRegressorEnsembleBatch.
ConformalPrediction._aggregate β Method
_aggregate(y, aggregate::Union{Symbol,String})Helper function that performs aggregation across vector of predictions.
ConformalPrediction.absolute_error β Method
absolute_error(y,yΜ)Computes abs(y - yΜ) where yΜ is the predicted value.
ConformalPrediction.blockbootstrap β Method
blockbootstrap(time_series_data, block_szie)
Generate a sampling method, that block bootstraps the given dataConformalPrediction.compute_interval β Method
compute_interval(fΞΌ, fvar, qΜ)compute the credible interval for a treshold score of qΜ under the assumption that each data point pdf is a gaussian distribution with mean fΞΌ and variance fvar. More precisely, assuming that f(x) is the pdf of a Gaussian, it computes the values of x so that f(x) > -q, or equivalently ln(f(x))> ln(-q). The end result is the interval [ ΞΌ - \sigma\sqrt{-2 *ln(-q \sigma \sqrt{2 \pi} )},ΞΌ + \sigma\sqrt{-2 *ln(-q \sigma \sqrt{2 \pi} )}]
inputs:
- fΞΌ array of the mean values
- fvar array of the variance values
- qΜ the treshold.
return:
- hcat(lower_bound, upper_bound) where lower_bound and upper_bound are,respectively, the arrays of the lower bounds and upper bounds for each data point.ConformalPrediction.conformal_bayes_score β Method
ConformalBayes(y, fΞΌ, fvar)computes the conformal score as the negative of probability of observing a value y given a Gaussian distribution with mean fΞΌ and a variance Ο^2 N(y|fΞΌ,Ο^2). In other words, it computes -1/(sqrt(Ο 2Ο)) * e^[-(y- fΞΌ)^2/(2*Ο^2)]
inputs:
- y the true values of the calibration set.
- fΞΌ array of the mean values
- fvar array of the variance values
return:
- the probability of observing a value y given a mean fΞΌ and a variance fvar.ConformalPrediction.is_classification β Method
is_classification(yΜ)Helper function that checks if conformal prediction yΜ comes from a conformal classification model.
ConformalPrediction.is_covered β Method
is_covered(yΜ, y)Helper function to check if y is contained in conformal region. Based on whether conformal predictions yΜ are set- or interval-valued, different checks are executed.
ConformalPrediction.is_covered_interval β Method
is_covered_interval(yΜ, y)Helper function to check if y is contained in conformal interval.
ConformalPrediction.is_covered_set β Method
is_covered_set(yΜ, y)Helper function to check if y is contained in conformal set.
ConformalPrediction.is_regression β Method
is_regression(yΜ)Helper function that checks if conformal prediction yΜ comes from a conformal regression model.
ConformalPrediction.minus_softmax β Method
minus_softmax(y,yΜ)Computes 1.0 - yΜ where yΜ is the softmax output for a given class.
ConformalPrediction.qminus β Function
qminus(v::AbstractArray, coverage::AbstractFloat=0.9)Implements the $\hat{q}_{n,\alpha}^{-}$ finite-sample corrected quantile function as defined in Barber et al. (2020): https://arxiv.org/pdf/1905.02928.pdf.
ConformalPrediction.qplus β Function
qplus(v::AbstractArray, coverage::AbstractFloat=0.9)Implements the $\hat{q}_{n,\alpha}^{+}$ finite-sample corrected quantile function as defined in Barber et al. (2020): https://arxiv.org/pdf/1905.02928.pdf.
ConformalPrediction.reformat_interval β Method
reformat_interval(yΜ)Reformats conformal interval predictions.
ConformalPrediction.reformat_mlj_prediction β Method
reformat_mlj_prediction(yΜ)A helper function that extracts only the output (predicted values) for whatever is returned from MMI.predict(model, fitresult, Xnew). This is currently used to avoid issues when calling MMI.predict(model, fitresult, Xnew) in pipelines.
ConformalPrediction.score β Function
score(conf_model::SimpleInductiveClassifier, ::Type{<:Supervised}, fitresult, X, y::Union{Nothing,AbstractArray}=nothing)Score method for the SimpleInductiveClassifier dispatched for any <:Supervised model.
ConformalPrediction.score β Function
score(conf_model::ConformalProbabilisticSet, fitresult, X, y=nothing)Generic score method for the ConformalProbabilisticSet. It computes nonconformity scores using the heuristic function h and the softmax probabilities of the true class. Method is dispatched for different Conformal Probabilistic Sets and atomic models.
ConformalPrediction.score β Function
score(conf_model::AdaptiveInductiveClassifier, ::Type{<:Supervised}, fitresult, X, y::Union{Nothing,AbstractArray}=nothing)Score method for the AdaptiveInductiveClassifier dispatched for any <:Supervised model.