# Enhancing Data Integrity in Blockchain Oracles Through Multi-Label Analysis
## 3 Methods
### Selection of Methods and Evaluation Based on State-of-the-Art Metrics
To use the proposed Integrity Multi-level Weighted Voting (IMWV), the data integrity scenario initially expresses hard voting as follows:  
\[\hat{y}=\underset{C_{k}}{argmax}\underset{i-1}{\overset{N}{\sum}}1\left(f_{i} (x)=C_{k}\right) \tag{1}\]  
In this equation:  
* \(\hat{y}\) is the final prediction;
* \(f_{i}(x)\) represents the prediction of the model \(i\) for input \(x\);  
Figure 6: Performance comparison of hard and soft voting techniques in multi-label classification. \(C_{k}\) is class \(k\);
* \(N\) is the number of models considered;
* \(1\) (\(f_{i}(x)=C_{k}\)) is an indicator function that counts how many models predict class \(C_{k}\). This model selects the class that receives the most votes among the models, allowing the smart contract to choose the best option when evaluating the integrity of the data. The process ensures that the data meet the established criteria. The proposal for integrity validation considers four key characteristics: accuracy, reliability, completeness, and consistency. It combines the hard voting method with a weighting technique that distributes variable weights across these integrity characteristics. The proposal includes a formal mathematical approach, pseudocode, and a detailed numerical example, illustrating the implementation process in which each model contributes a specific weight to the final vote. The proposal considers multi-label prediction models, represented as \(M_{1}\), \(M_{2}\),..., \(M_{k}\), responsible for generating predictions for each test instance. Specific integrity metrics are calculated for each model \(M_{i}\):  
* Precision (_Prec_): Evaluates the accuracy of the data provided by the oracle regarding the actual values. * Reliability (_C_rec_): Measures the oracle's ability to maintain data consistency over time. * Completeness (_C_com_): Assesses if the data are complete and covers all necessary aspects for the smart contract. * Consistency (_C_cons_): Measures the coherence of the provided data, both within the same source and across different sources. Each integrity characteristic has a relevance value that reflects its relative impact on the quality of the oracle's data. The relevance of each characteristic \(R_{label}\) is calculated as the proportion of its effects within the Oracle system. It is formalized as follows:  
\[R_{label}=\frac{V_{label}}{\sum_{label}V_{label}} \tag{2}\]  
where \(V_{label}\) is the value assigned to the integrity characteristic \(label\), reflecting its impact on the quality of data. Once the relevance of each characteristic is calculated, a weight is assigned to each characteristic based on its significance. The weights \(W_{label}\) are calculated by normalizing the relevance of each characteristic so that the sum of all weights equals 1:  
\[W_{label}=\frac{R_{label}}{\sum_{label}R_{label}} \tag{3}\]  
This step ensures that the weights reflect the relative importance of each characteristic in the final voting process. For this system, the weights \(W_{Prec}\), \(W_{C\_rec}\), \(W_{C\_com}\), \(W_{C\_cons}\) represent the relative importance of each integrity characteristic. In this example, the following weights are assigned, where Figure 7 shows the representation of each initial integrity characteristic in this scenario:  
\[W_{Prec}=0.4,W_{C\_rec}=0.2,W_{C\_com}=0.3,W_{C\_cons}=0.1 \tag{4}\]As data is collected and the system evolves, the weights assigned to the integrity characteristics can be adjusted dynamically. It is achieved through a learning rate \(\eta\), which updates the weights based on the impact of each characteristic on decision making. The formula for dynamic updating is as follows:  
\[W_{label}(t+1)=W_{label}(t)+\eta\cdot\Delta_{label}(t) \tag{5}\]  
where \(\Delta_{label}(t)\) is the change in the relevance of the characteristic during iteration \(t\), calculated as:  
\[\Delta_{label}(t)=\frac{impact_{label}(t)}{\sum_{label}impact_{label}(t)} \tag{6}\]  
This process allows the weights to adjust continuously to better reflect the system's current state.