AbstractIntegratedModule 1.0.4__tar.gz → 1.0.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.py +185 -162
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractOptimizedModules.c +200 -200
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/PKG-INFO +1 -1
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/README.md +3 -3
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/pyproject.toml +1 -1
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/setup.py +1 -1
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/MANIFEST.in +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/setup.cfg +0 -0
{abstractintegratedmodule-1.0.4 → abstractintegratedmodule-1.0.5}/AbstractIntegratedModule.py
RENAMED
|
@@ -16996,201 +16996,222 @@ class PipelinePredictionManager:
|
|
|
16996
16996
|
if isinstance(confidence, (np.ndarray, list)):
|
|
16997
16997
|
confidence = np.mean(confidence)
|
|
16998
16998
|
|
|
16999
|
-
|
|
16999
|
+
return_single_condition = (
|
|
17000
|
+
not self.pipeline.use_transformer or
|
|
17001
|
+
not need_ensemble_method
|
|
17000
17002
|
|
|
17001
|
-
|
|
17002
|
-
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17006
|
-
|
|
17007
|
-
|
|
17008
|
-
|
|
17009
|
-
|
|
17010
|
-
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
|
|
17014
|
-
|
|
17015
|
-
|
|
17016
|
-
if final_idx > len(reverse_map):
|
|
17017
|
-
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17018
|
-
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17019
|
-
final_idx = int(final_idx)
|
|
17020
|
-
|
|
17021
|
-
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17022
|
-
if chosen_label.startswith('unknown'):
|
|
17023
|
-
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17024
|
-
|
|
17025
|
-
try:
|
|
17026
|
-
print(final_probs)
|
|
17027
|
-
confidence = float(final_probs[final_idx])
|
|
17028
|
-
except:
|
|
17029
|
-
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17030
|
-
|
|
17031
|
-
elif self.pipeline.autonomous and need_peer_condition and attn_weights is not None:
|
|
17032
|
-
if agreement is None:
|
|
17033
|
-
agreement = False
|
|
17034
|
-
|
|
17035
|
-
print('[||] Iniating local peer output search in database for best output...')
|
|
17036
|
-
final_probs = self.pipeline.distribution._handle_peer_agent_request(final_probs, attn_weights, input_ids, type='DevicePeer', agreement=agreement)
|
|
17037
|
-
|
|
17038
|
-
final_idx = final_probs[0].argmax()
|
|
17039
|
-
original_idx = final_idx
|
|
17003
|
+
)
|
|
17004
|
+
if return_single_condition:
|
|
17005
|
+
print('[=] Displaying Results....')
|
|
17006
|
+
if not results[0].get('models_agree', True) and self.pipeline.use_transformer:
|
|
17007
|
+
trans_confidence = results[0].get('trans_confidence', 1e-8)
|
|
17008
|
+
confidence = (confidence + trans_confidence / 2) + 1e-5
|
|
17009
|
+
print(f'[=] Calibrating confidence around: {confidence:.1%} Due to disagreement between Transformer and MLP.')
|
|
17010
|
+
|
|
17011
|
+
print(f"\n[🎯] Predicted label: {chosen_label} || With Certain Confidence: {confidence:.1%}")
|
|
17012
|
+
payload = {
|
|
17013
|
+
'X_samples': X,
|
|
17014
|
+
'input_ids': input_ids
|
|
17015
|
+
}
|
|
17016
|
+
if titles is not None and len(titles) > 0:
|
|
17017
|
+
correct, sec_correct = self.display_hybrid_results(payload, final_class_idx, results, top_k, verbose=True)
|
|
17040
17018
|
|
|
17041
|
-
|
|
17042
|
-
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17043
|
-
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17044
|
-
final_idx = int(final_idx)
|
|
17019
|
+
return results, chosen_label, confidence
|
|
17045
17020
|
|
|
17046
|
-
|
|
17047
|
-
|
|
17048
|
-
|
|
17049
|
-
|
|
17050
|
-
|
|
17021
|
+
else:
|
|
17022
|
+
if results[0].get('models_agree', True) and confidence > self.pipeline.confidence_threshold and not chosen_label.startswith("unknown"):
|
|
17023
|
+
print(f"\n[🎯] Proper Confidence of Final chosen label for input: {chosen_label} || Confidence: {confidence:.1%}")
|
|
17024
|
+
return results, chosen_label, confidence
|
|
17025
|
+
|
|
17026
|
+
# Only recalibrate if models disagreed
|
|
17027
|
+
elif results and not results[0].get('models_agree', True) or not self.pipeline.agreement and self.pipeline.use_transformer:
|
|
17051
17028
|
|
|
17029
|
+
need_peer_condition = not results[0].get('models_agree', True) and self.pipeline.peer_assistance_threshold > 0.3 and self.pipeline.use_transformer
|
|
17030
|
+
print("\n[⚠️] Disagreement detected between MLP and Transformer predictions. Usig calibrated probabilities for final decision.")
|
|
17031
|
+
if confidence < self.pipeline.confidence_threshold and need_peer_condition:
|
|
17032
|
+
print('|| Uncertain advanced prediction, requesting peer assistance if allowed...')
|
|
17033
|
+
final_probs = self.pipeline._handle_distributed_connections(final_probs, attn_weights, input_ids, agreement)
|
|
17052
17034
|
|
|
17053
|
-
elif not results[0].get('models_agree', True) and confidence > self.pipeline.confidence_threshold:
|
|
17054
|
-
if final_confidence is not None and confidence < self.pipeline.confidence_threshold:
|
|
17055
|
-
print("\n[⚠️] Low confidence detected, but both models don't agree. Using calibrated probabilities for final decision to ensure robustness.")
|
|
17056
|
-
final_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset, X=X, y=y, use_embedded=use_embedded)
|
|
17057
|
-
|
|
17058
17035
|
final_idx = final_probs[0].argmax()
|
|
17059
17036
|
original_idx = final_idx
|
|
17060
|
-
|
|
17037
|
+
|
|
17061
17038
|
if final_idx > len(reverse_map):
|
|
17062
17039
|
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17063
17040
|
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17064
17041
|
final_idx = int(final_idx)
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
|
|
17069
|
-
final_idx = final_probs[0].argmax()
|
|
17070
|
-
original_idx = final_idx
|
|
17071
|
-
if final_idx > len(reverse_map):
|
|
17042
|
+
|
|
17043
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17044
|
+
if chosen_label.startswith('unknown'):
|
|
17072
17045
|
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17073
|
-
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17074
|
-
final_idx = int(final_idx)
|
|
17075
17046
|
|
|
17076
|
-
|
|
17077
|
-
|
|
17078
|
-
|
|
17079
|
-
|
|
17080
|
-
|
|
17081
|
-
|
|
17082
|
-
|
|
17083
|
-
|
|
17084
|
-
|
|
17085
|
-
|
|
17086
|
-
|
|
17047
|
+
try:
|
|
17048
|
+
confidence = float(final_probs[final_idx])
|
|
17049
|
+
except:
|
|
17050
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17051
|
+
|
|
17052
|
+
elif self.pipeline.autonomous and need_peer_condition and attn_weights is not None:
|
|
17053
|
+
if agreement is None:
|
|
17054
|
+
agreement = False
|
|
17055
|
+
|
|
17056
|
+
print('[||] Iniating local peer output search in database for best output...')
|
|
17057
|
+
final_probs = self.pipeline.distribution._handle_peer_agent_request(final_probs, attn_weights, input_ids, type='DevicePeer', agreement=agreement)
|
|
17058
|
+
|
|
17087
17059
|
final_idx = final_probs[0].argmax()
|
|
17088
|
-
original_idx = final_idx
|
|
17060
|
+
original_idx = final_idx
|
|
17089
17061
|
|
|
17090
17062
|
if final_idx > len(reverse_map):
|
|
17091
17063
|
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17092
17064
|
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17093
|
-
final_idx = int(final_idx)
|
|
17065
|
+
final_idx = int(final_idx)
|
|
17094
17066
|
|
|
17095
17067
|
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17096
17068
|
try:
|
|
17097
|
-
confidence = float(final_probs[
|
|
17069
|
+
confidence = float(final_probs[final_idx])
|
|
17098
17070
|
except:
|
|
17099
|
-
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17100
|
-
else:
|
|
17101
|
-
if final_probs is None:
|
|
17102
|
-
final_probs = mlp_probs
|
|
17071
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17103
17072
|
|
|
17104
|
-
final_probs = self.calibration_penalized_check(final_probs, target_pred_indices[0])
|
|
17105
17073
|
|
|
17106
|
-
|
|
17074
|
+
elif not results[0].get('models_agree', True) and confidence > self.pipeline.confidence_threshold:
|
|
17075
|
+
if final_confidence is not None and confidence < self.pipeline.confidence_threshold:
|
|
17076
|
+
print("\n[⚠️] Low confidence detected, but both models don't agree. Using calibrated probabilities for final decision to ensure robustness.")
|
|
17077
|
+
final_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset, X=X, y=y, use_embedded=use_embedded)
|
|
17107
17078
|
|
|
17108
|
-
|
|
17109
|
-
|
|
17110
|
-
|
|
17111
|
-
final_idx
|
|
17112
|
-
|
|
17113
|
-
|
|
17079
|
+
final_idx = final_probs[0].argmax()
|
|
17080
|
+
original_idx = final_idx
|
|
17081
|
+
|
|
17082
|
+
if final_idx > len(reverse_map):
|
|
17083
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17084
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17085
|
+
final_idx = int(final_idx)
|
|
17086
|
+
else:
|
|
17087
|
+
print('[🎯] Stable confidence established, But both Models doesnt Agree, Re-evaluating...')
|
|
17088
|
+
final_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset, X=X, y=y, use_embedded=use_embedded)
|
|
17089
|
+
|
|
17090
|
+
final_idx = final_probs[0].argmax()
|
|
17091
|
+
original_idx = final_idx
|
|
17092
|
+
if final_idx > len(reverse_map):
|
|
17093
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17094
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17095
|
+
final_idx = int(final_idx)
|
|
17114
17096
|
|
|
17115
17097
|
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17116
|
-
if final_probs is None:
|
|
17117
|
-
final_probs = target_probs.copy()
|
|
17118
|
-
|
|
17119
17098
|
try:
|
|
17099
|
+
confidence = float(final_probs[0][final_idx])
|
|
17100
|
+
except:
|
|
17101
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17102
|
+
else:
|
|
17103
|
+
if self.pipeline.use_transformer and need_ensemble_method:
|
|
17104
|
+
print("\n[⚠️] Uncertain confidence and disagreement detected. Using ensemble method for final decision.")
|
|
17105
|
+
input_forward = sequence_ids if sequence_ids is not None else input_ids
|
|
17106
|
+
final_probs, details = self.pipeline.ensemble.predict_ensemble(input_forward, X, y, method='dynamic', embedded=use_embedded)
|
|
17107
|
+
|
|
17108
|
+
final_idx = final_probs[0].argmax()
|
|
17109
|
+
original_idx = final_idx
|
|
17110
|
+
|
|
17111
|
+
if final_idx > len(reverse_map):
|
|
17112
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17113
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17114
|
+
final_idx = int(final_idx)
|
|
17115
|
+
|
|
17116
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17120
17117
|
try:
|
|
17121
17118
|
confidence = float(final_probs[0][final_idx])
|
|
17122
17119
|
except:
|
|
17123
17120
|
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17124
|
-
|
|
17121
|
+
else:
|
|
17122
|
+
if final_probs is None:
|
|
17123
|
+
final_probs = mlp_probs
|
|
17124
|
+
|
|
17125
|
+
final_probs = self.calibration_penalized_check(final_probs, target_pred_indices[0])
|
|
17126
|
+
|
|
17127
|
+
final_idx = final_probs[0].argmax() if final_probs is not None else target_probs[0].argmax()
|
|
17128
|
+
|
|
17129
|
+
original_idx = final_idx
|
|
17130
|
+
|
|
17131
|
+
if final_idx > len(reverse_map):
|
|
17132
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17133
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17134
|
+
final_idx = int(final_idx)
|
|
17135
|
+
|
|
17136
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17137
|
+
if final_probs is None:
|
|
17138
|
+
final_probs = target_probs.copy()
|
|
17139
|
+
|
|
17125
17140
|
try:
|
|
17126
|
-
|
|
17141
|
+
try:
|
|
17142
|
+
confidence = float(final_probs[0][final_idx])
|
|
17143
|
+
except:
|
|
17144
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17127
17145
|
except:
|
|
17128
|
-
|
|
17146
|
+
try:
|
|
17147
|
+
confidence = float(final_probs[final_idx])
|
|
17148
|
+
except:
|
|
17149
|
+
confidence = self.pipeline.confidence_threshold
|
|
17129
17150
|
|
|
17130
|
-
|
|
17131
|
-
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17151
|
+
elif confidence < self.pipeline.confidence_threshold and not self.pipeline.agreement and not results[0].get('models_agree', True):
|
|
17152
|
+
if trans_probs is not None:
|
|
17153
|
+
prob_entropy = self.calculate_entropy(final_probs)
|
|
17154
|
+
normalized_entropy = prob_entropy / np.log(prob_entropy.shape[-1]) if prob_entropy.shape[-1] > 1 else 0
|
|
17155
|
+
attn_quality = 1.0 / (1.0 + np.exp(-attn_weights.mean()) + eps) if attn_weights is not None else 0.5
|
|
17156
|
+
anisotropy = self.pipeline.anisotropy_measurement(attn_weights.mean() if attn_weights is not None else 0.5)
|
|
17136
17157
|
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17140
|
-
|
|
17141
|
-
|
|
17142
|
-
|
|
17143
|
-
|
|
17144
|
-
|
|
17145
|
-
|
|
17146
|
-
|
|
17147
|
-
|
|
17148
|
-
|
|
17149
|
-
|
|
17150
|
-
|
|
17158
|
+
else:
|
|
17159
|
+
normalized_entropy = self.calculate_entropy(input_ids) # Max entropy for uniform distribution
|
|
17160
|
+
attn_quality = self.pipeline.confidence_threshold
|
|
17161
|
+
anisotropy = self.anisotropy_measurement(input_ids) if hasattr(self.pipeline, 'anisotropy_measurement') else 0.5
|
|
17162
|
+
|
|
17163
|
+
mean_entropy = np.mean(normalized_entropy)
|
|
17164
|
+
|
|
17165
|
+
use_simple_prediction = (
|
|
17166
|
+
anisotropy < 0.3 or
|
|
17167
|
+
mean_entropy < 0.5 or # High uncertainty
|
|
17168
|
+
results[0].get('confidence', 0) < 0.4 or # Low confidence
|
|
17169
|
+
not results[0].get('models_agree', True) or # Disagreement
|
|
17170
|
+
attn_quality < 0.4
|
|
17171
|
+
)
|
|
17151
17172
|
|
|
17152
|
-
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
|
|
17156
|
-
|
|
17157
|
-
|
|
17173
|
+
if use_simple_prediction:
|
|
17174
|
+
print("\n[⚡] Condition is poorly unviable to handle agreement. Using robust prediction method for better reliability.")
|
|
17175
|
+
predicted_label, confidence = self.simple_pass_prediction(self.pipeline, titles=titles, label_map=label_map, X_raw=X, y=y, show_proba=show_proba, top_k=top_k)
|
|
17176
|
+
if predicted_label is not None:
|
|
17177
|
+
print(f"\n[🎯] Robust prediction result: {predicted_label} with confidence {confidence:.1%}")
|
|
17178
|
+
return _, predicted_label, confidence
|
|
17179
|
+
|
|
17180
|
+
else:
|
|
17181
|
+
final_idx = final_probs[0].argmax()
|
|
17182
|
+
original_idx = final_idx
|
|
17183
|
+
|
|
17184
|
+
if final_idx > len(reverse_map):
|
|
17185
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17186
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17187
|
+
final_idx = int(final_idx)
|
|
17188
|
+
|
|
17189
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17190
|
+
if final_probs is not None:
|
|
17191
|
+
try:
|
|
17192
|
+
confidence = float(final_probs[0][final_idx])
|
|
17193
|
+
except:
|
|
17194
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17195
|
+
|
|
17196
|
+
else:
|
|
17197
|
+
final_probs = target_probs.copy()
|
|
17158
17198
|
|
|
17159
17199
|
else:
|
|
17200
|
+
print("\n[🎯] Using initial Regular final prediction as final decision.")
|
|
17160
17201
|
final_idx = final_probs[0].argmax()
|
|
17161
|
-
original_idx = final_idx
|
|
17162
17202
|
|
|
17163
17203
|
if final_idx > len(reverse_map):
|
|
17164
17204
|
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
17165
|
-
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17166
|
-
final_idx = int(final_idx)
|
|
17205
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
17206
|
+
final_idx = int(final_idx)
|
|
17167
17207
|
|
|
17168
17208
|
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17169
|
-
if final_probs is not None:
|
|
17170
|
-
try:
|
|
17171
|
-
confidence = float(final_probs[0][final_idx])
|
|
17172
|
-
except:
|
|
17173
|
-
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17174
|
-
|
|
17175
|
-
else:
|
|
17176
|
-
final_probs = target_probs.copy()
|
|
17177
|
-
|
|
17178
|
-
else:
|
|
17179
|
-
print("\n[🎯] Using initial Regular final prediction as final decision.")
|
|
17180
|
-
final_idx = final_probs[0].argmax()
|
|
17181
17209
|
|
|
17182
|
-
|
|
17183
|
-
|
|
17184
|
-
|
|
17185
|
-
|
|
17186
|
-
|
|
17187
|
-
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
17188
|
-
|
|
17189
|
-
try:
|
|
17190
|
-
confidence = float(final_probs[0][final_idx])
|
|
17191
|
-
except:
|
|
17192
|
-
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17193
|
-
|
|
17210
|
+
try:
|
|
17211
|
+
confidence = float(final_probs[0][final_idx])
|
|
17212
|
+
except:
|
|
17213
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
17214
|
+
|
|
17194
17215
|
if confidence > 0.8:
|
|
17195
17216
|
confidence = (confidence + performance_score) / 2
|
|
17196
17217
|
print(f'[⚡] Confidence calibrated to be around: {confidence}')
|
|
@@ -17198,7 +17219,7 @@ class PipelinePredictionManager:
|
|
|
17198
17219
|
if isinstance(chosen_label, str) and chosen_label.startswith("unknown") or float(confidence) < self.pipeline.confidence_threshold:
|
|
17199
17220
|
if chosen_label.startswith("unknown"):
|
|
17200
17221
|
chosen_label = 'Unknown'
|
|
17201
|
-
confidence = 1.0 - confidence #
|
|
17222
|
+
confidence = 1.0 - confidence #Invert confidence for unknown class
|
|
17202
17223
|
|
|
17203
17224
|
print(f"\n[⚠️] Final prediction is {chosen_label} with uncertain confidence: {confidence:.1%}. Consider more consistent data for the model to learn from.")
|
|
17204
17225
|
else:
|
|
@@ -17380,15 +17401,17 @@ class PipelinePredictionManager:
|
|
|
17380
17401
|
self.error_counts[result.get('predicted_idx')] += 1.0
|
|
17381
17402
|
|
|
17382
17403
|
if result['predicted'] == result['expected']:
|
|
17383
|
-
if result['sec_index'] is None:
|
|
17404
|
+
if 'sec_index' in result and result['sec_index'] is None:
|
|
17384
17405
|
result['sec_index'] = None
|
|
17385
17406
|
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17407
|
+
if 'predicted_idx' in result and 'confidence' in result and 'predicted' in result:
|
|
17408
|
+
self.pipeline.accurate_cache_lookup.add_verified(
|
|
17409
|
+
X_samples, input_ids,
|
|
17410
|
+
result['predicted'], result['confidence'], result['predicted_idx'],
|
|
17411
|
+
source='automatic_verified')
|
|
17390
17412
|
|
|
17391
|
-
|
|
17413
|
+
correct += 1
|
|
17414
|
+
|
|
17392
17415
|
else:
|
|
17393
17416
|
error += 1
|
|
17394
17417
|
if isinstance(self.error_counts[result.get('predicted_idx')], (int, float)):
|
|
@@ -17716,7 +17739,7 @@ class ConsecutivePeerAgent:
|
|
|
17716
17739
|
|
|
17717
17740
|
best_result = local_result
|
|
17718
17741
|
|
|
17719
|
-
# Step 2: If low confidence,
|
|
17742
|
+
# Step 2: If low confidence, asking peers
|
|
17720
17743
|
if local_result['confidence'] < confidence_threshold and peer_addresses or peer_addresses:
|
|
17721
17744
|
if local_result['confidence'] < confidence_threshold:
|
|
17722
17745
|
print(f"[ConsecutivePeerAgent] Low confidence, asking {len(peer_addresses)} peers...")
|
|
@@ -18329,11 +18352,11 @@ class CohesiveAgentDeployment:
|
|
|
18329
18352
|
|
|
18330
18353
|
# Send heartbeat to check connection
|
|
18331
18354
|
try:
|
|
18332
|
-
|
|
18333
|
-
|
|
18334
|
-
|
|
18335
|
-
|
|
18336
|
-
|
|
18355
|
+
self.pipeline.distribution._send_message(
|
|
18356
|
+
sock, {'type': 'PING', 'timestamp': time.time()}
|
|
18357
|
+
)
|
|
18358
|
+
sock.getpeername()
|
|
18359
|
+
print(f'[==] Peer name: {sock.getpeername()}')
|
|
18337
18360
|
except:
|
|
18338
18361
|
logger.warning(f"[-] Peer {peer_host}:{peer_port} disconnected")
|
|
18339
18362
|
break
|