# Enhancing Data Integrity in Blockchain Oracles Through Multi-Label Analysis
## 3 Methods
### Selection of Methods and Evaluation Based on State-of-the-Art Metrics
* \(w_{Prec}=R_{Prec}=0.2426\) \(w_{C\_rec}=R_{C\_rec}=0.2727\) \(w\_{C\_com}=R_{C\_com}=0.2575\) \(w\_{C\_cons}=R_{C\  
Figure 5:1 Figure 5:2 Figure 5:3 Model Predictions: Class 1: Contributions from \(M1,\ M2,\ M4\) Models predicting 1: Figure 5:4 Total Weighted Votes for Class \(1=0.8786+0.8500+0.8293=2.5579\) Class 0: Contributions from \(M3\) Models predicting 0: Figure 5:5 Total Weighted Votes for Class \(0=0.8424\) The class with the highest cumulative weight is selected as the final prediction: Selected Class : Class \(1=2.5579\) (highest cumulative weight)  
Step 6: After determining the final class through the weighted voting process, the next step is identifying the best-performing model among those predicting the final class. This is achieved by comparing their total weighted contributions. Figure 5:6 Figure 5:7 Figure 5:8  
Best model: \(M1\) (highest contribution: 0.8786)  
In Algorithm 1, we show a smart contract based on the pseudocode, which represents the application of the coffee futures contract scenario. This contract was designed to ensure the integrity of the data related to coffee production by utilizing an oracle and a voting system based on bagging models, as described previously. We developed The CoffeeFuturesContract smart contract specifically to manage and validate these data. It allows coffee producers to request validation of the data being processed. By invoking the validateData() function, the validity of the data is verified through a multi-level weighted voting process. This voting system considers the contribution of different prediction models, weighted according to their performance in integrity characteristics such as accuracy, reliability, completeness, and consistency. In this way, the contract ensures that only validated data are used in coffee futures transactions. ```
# Input: #--Set of models \(M=\{M1,M2,M3,M4\}\), each with: #--Individual prediction \(V_{i}\) for model \(M_{i}\) (0 or 1 for binary labels) #--Integrity score \(S_{i}\) for model \(M_{i}\) #--Integrity characteristics: Precision, Reliability, Completeness, Consistency #--Weights \(W\) for each integrity characteristic (initial weights must sum to 1) #--Learning rate \(\eta\) for dynamic weight adjustment #--Number of iterations for updates (optional, based on system needs)
```
**Algorithm 1**_Cont._
```
# Step 1: Definition of Integrity Characteristics class IntegrityCharacteristics: def__init__(self, precision, reliability, completeness, consistency): self.precision = precision self.reliability = reliability self.completeness = completeness self.consistency = consistency
```
**Algorithm 2**_Cont._
```
# Step 2: Calculate the Relevance of Integrity Characteristics def calculate_relevance(characteristics): total_value = sum([characteristics.precision, characteristics.reliability, characteristics.completeness, characteristics.consistency]) relevance = { \"precision\": characteristics.precision/total_value, \"reliability\": characteristics.reliability/total_value, \"completeness\": characteristics.completeness/total_value, \"consistency\": characteristics.consistency/total_value} return relevance
```  
**Algorithm 3**_Cont._  
**# Step 3: Assign Weights to Integrity Characteristics def assign_weights(relevance): total_relevance = sum(relevance.values()) weights = {key: value/total_relevance for key, value in relevance.items()} return weights # Step 4: Dynamic Update of Weights def update_weights(weights, delta, learning_rate): for label in weights: weights[label] += learning_rate * delta[label] return weights # Step 5: Weighted Voting Method def weighted_voting(models, weights): scores = {0: 0, 1: 0} for model in models: prediction = model['prediction'] integrity_score = model['integrity_score'] weighted_contribution = integrity_score * prediction # Update the score for the corresponding class (0 or 1) scores[prediction] += weighted_contribution # Select the class with the highest score final_class = max(scores, key=scores.get) return final_class