# A Robust Conformal Framework for IoT-Based Predictive Maintenance
## 3 CI Estimation in Predictive Maintenance
### Conformal Prediction  
CP is a robust machine learning framework that provides valid confidence measurements for individual predictions. Predictions made by ML or DL often come without the UQ, which is required for confident and reliable decision-making in the real world. Quantifying uncertainty is a prerequisite for explainability and trust in machine learning models. Using any model within the CP framework generates predictions and quantifies the confidence in those predictions. Several different approaches to quantifying uncertainty exist, such as statistical methods, Bayesian methods, and fuzzy logic methods [32]. Statistical methods are widely used for UQ and involve using probability distributions to model the uncertainty in data and prediction. Bayesian methods use prior knowledge and data to update beliefs about the uncertainty in predictions. Fuzzy logic involves using sets and membership functions to represent uncertainty in a system. Considering the CP framework, there are three primary approaches to estimating CI, such as NCP (Naive Conformal Prediction), BCP (Bootstrapping-Based Conformal Prediction), and WCP (Weighted Conformal Prediction) [33; 34; 35]. To perform CP, the first critical step is to calculate the nonconformity score, which measures how unusual or non-conforming the observed data are compared with the predicted values. Generally, it measures how much the model's prediction deviates from reality. NCP is the most straightforward approach to estimating the nonconformity score. It computed the nonconformity score for each data point by the difference between observed values and predicted values. It is computed directly using this formula:  
\[s_{i}=|Y_{i}-\hat{f}(X_{i})| \tag{11}\]  
where \(Y_{i}\) is the observed value for the \(i\)-th data point and \(\hat{f}(X_{i})\) is the predicted value from the model for input \(X_{i}\). However, in BCP, the nonconformity score is calculated by resampling techniques. For each BCP sample \(b\), the nonconformity score is computed by the same formula as in NCP. In BCP, multiple samples are generated from the original dataset. For each sample of BCP,the nonconformity score is calculated as the absolute difference between the predicted and observed values. The formula for calculating the nonconformity score of the BCP sample is  
\[s_{i}^{(b)}=|Y_{i}-\hat{f}^{(b)}(X_{i})| \tag{12}\]  
where \(\hat{f}^{(b)}(X_{i})\) is the model trained on the \(i\)-th BCP sample. The WCP is the extent of the NCP, which assigns weight \(w_{i}\) to calibration points. By assigning weight \(w_{i}\), the CP reflects the importance of the \(i\)-th calibration point (e.g., based on time proximity, relevance, or domain-specific knowledge). The formula for calculating the nonconformity score using weight is  
\[s_{i}=w_{i}\cdot|Y_{i}-\hat{f}(X_{i})| \tag{13}\]  
where \(w_{i}\) is the weight reflecting the relative importance. After computing the nonconformity scores for the three different approaches--NCP, BCP, and WCP--the next step is to calculate the quantile threshold using the significance level \(\alpha\). This threshold ensures that the CI achieves the desired coverage probability. The specific method for determining the threshold varies depending on the approach, but all rely on the \((1-\alpha)\)-th quantile of the nonconformity scores. In NCP, the quantile threshold is determined as  
\[q_{1-\alpha}=\text{quantile}_{1-\alpha}\{s_{1},s_{2},\ldots,s_{n}\} \tag{14}\]  
where \(q_{1-\alpha}\) is the \((1-\alpha)\)-th quantile of the calibration scores and \(\{s_{1},s_{2},\ldots,s_{n}\}\) represents the set of nonconformity scores. For BCP sample \(b\), the quantile threshold is determined as  
\[q_{1-\alpha}=\text{quantile}_{1-\alpha}\{s_{1}^{(1)},s_{2}^{(1)},\ldots,s_{n}^ {(B)}\} \tag{15}\]  
where \(B\) is the total number of BCP samples. For WCP, the nonconformity score is calculated using the weight \(w_{i}\).