# A Robust Conformal Framework for IoT-Based Predictive Maintenance
## 3 CI Estimation in Predictive Maintenance
### Conformal Prediction
So, a weighted quantile is used to compute the threshold as follows:  
\[q_{1-\alpha}=\text{weighted\_quantile}_{1-\alpha}\{s_{1},s_{2},\ldots,s_{n}\} \tag{16}\]  
where the weighted_quantile accounts for the relative importance of each score based on the assigned weights. The final formula for computing the CI is the same for all three methods. To calculate the CI, include all candidate values \(Y\) that satisfy \(s_{n+1}\leq q_{1-\alpha}\), where \(s_{n+1}\) is the nonconformity score for the new prediction and \(q_{1-\alpha}\) is the quantile threshold computed differently depending on the methods as the following formula:  
\[C(X_{n+1})=\{Y:s_{n+1}\leq q_{1-\alpha}\} \tag{17}\]  
\[P(Y_{n+1}\in C_{n}(X_{n+1}))\geq 1-\alpha \tag{18}\]  
This formula states that the probability of true response \(Y_{n+1}\) falling within the predicted confidence set \(C_{n}(X_{n+1})\) is at least \((1-\alpha)\). From the performance evaluation perspective, the key metrics for CP are margin, coverage, and average width. Margin is defined as the quantile of the absolute errors or nonconformity scores, which is computed on a calibration set. If a score is taken from the target coverage percentile, then this score will be added to and subtracted from the point prediction to form the prediction interval. A higher margin result is always a wider interval,which represents the prediction intervals with more stability and reliability. In comparison, a lower margin generates narrow intervals that provide more precise estimates but are less robust. Coverage measures the robustness of the predicted interval. It refers to the proportion of times when the actual value falls within the predicted CI. \[\text{Coverage}=\frac{1}{N}\sum_{i=1}^{N}\mathbf{1}\{y_{i}\in[\max\{0,\,\hat{y }_{i}-m\},\,\hat{y}_{i}]\}, \tag{19}\]  
The coverage value is presented in Equation (19), where \(N\) is the total number of predictions, \(\mathbf{1}\{\cdot\}\) is the indicator function that evaluates to 1 if the condition is true (and 0 otherwise), and \(\hat{y}_{i}\) is the point prediction for the \(i\)th sample. The \(m\) is the margin, which determines how well the predicted intervals capture the actual value. Lowering the coverage value means that its prediction intervals often fail to capture the actual values. In contrast, a higher coverage value indicates that actual values fall within the prediction intervals. The average width measures the size of the predicted intervals. It is calculated simply as the mean of the widths of all prediction intervals. Narrower intervals are more precise but may sacrifice coverage, while wider intervals are less accurate but more reliable. The calibration set is central to this process. It is used to compute the nonconformity scores that define the margin, ensuring that the selected margin reflects the model's performance on unseen data. This allows the integrity of the performance assessment to be maintained, as the metrics computed on the test set are not influenced by the margin selection process. In the above sections, we have explained the Prophet and CP methodologies to compute CI for predicted values. It is visible that these two approaches have different patterns when calculating CI. Prophet incorporates seasonality, trends, and holidays through simulation-based methods (e.g., Monte Carlo sampling or posterior predictive distributions), while CP relies on nonconformity scores and quantile thresholds in different methods (e.g., NCP, BCP, and WCP) to perform CI even under non-exchangeability conditions and data drifts.