AbstractIntegratedModule 1.1.1__tar.gz → 1.1.3__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.
Files changed (23) hide show
  1. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
  2. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.py +108 -42
  3. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractOptimizedModules.c +209 -201
  4. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/PKG-INFO +1 -1
  5. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/README.md +6 -5
  6. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/pyproject.toml +1 -1
  7. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/setup.py +1 -1
  8. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  9. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  10. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  11. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  12. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/AbstractOptimizedModules.pyx +0 -0
  13. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/MANIFEST.in +0 -0
  14. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/Cargo.toml +0 -0
  15. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/pyproject.toml +0 -0
  16. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/src/lib.rs +0 -0
  17. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  18. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  19. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  20. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  21. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  22. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  23. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 1.1.1
3
+ Version: 1.1.3
4
4
  Summary: Integrated Pipeline with Specialized Non-LLM AI Agent Framework for ARM64 architecture
5
5
  Author: Micro-Novelty
6
6
  Author-email: Micro-Novelty <hernikpuspita5@gmail.com>
@@ -21,6 +21,7 @@ from collections import defaultdict
21
21
  import hashlib
22
22
  import ssl
23
23
  import os
24
+ import glob
24
25
  import asyncio
25
26
  import queue
26
27
  import threading
@@ -1567,6 +1568,7 @@ class Transformer:
1567
1568
  acc = float(np.mean(preds == true))
1568
1569
 
1569
1570
  return loss, acc
1571
+
1570
1572
 
1571
1573
  def _sanitize_string_chars(self, x):
1572
1574
  if isinstance(x, (str, np.str_)):
@@ -2035,8 +2037,10 @@ class MLP:
2035
2037
  # re adapt shape of pred_counts and error_counts if they don't match prob shape
2036
2038
  if self.pred_counts.shape != prob.shape:
2037
2039
  self.pred_counts = np.zeros_like(prob)
2040
+ self.pred_counts *= decay
2038
2041
  if self.error_counts.shape != prob.shape:
2039
2042
  self.error_counts = np.zeros_like(prob)
2043
+ self.error_counts *= decay
2040
2044
 
2041
2045
  except Exception as e:
2042
2046
  print(f'[!] Cant check and calibrate probs based on penalty due to: {e}')
@@ -3900,9 +3904,6 @@ class CrossSessionAutomation:
3900
3904
  print(f"✅ Session imported! Total memories: {len(self.pipeline.memory)}")
3901
3905
 
3902
3906
  def sync_with_another_device(self, device_ip, port=5000):
3903
- import socket
3904
- import pickle
3905
-
3906
3907
  # Export current session
3907
3908
  temp_file = self.export_session(f"sync_{self.session_id}")
3908
3909
 
@@ -3920,8 +3921,6 @@ class CrossSessionAutomation:
3920
3921
 
3921
3922
 
3922
3923
  def list_sessions(self, name):
3923
- import glob
3924
-
3925
3924
  sessions = glob.glob(f"{name}*.json")
3926
3925
 
3927
3926
  print(f"\n📚 Available Sessions: {sessions}")
@@ -4268,7 +4267,7 @@ class ExplainabilityModule:
4268
4267
  if not self.learned_from_feedback:
4269
4268
  return
4270
4269
 
4271
- print(f"\n🔄 Consolidating {len(self.learned_from_feedback)} supervised memories...")
4270
+ print(f"\n[🔄] Consolidating {len(self.learned_from_feedback)} supervised memories...")
4272
4271
 
4273
4272
  # Extract all supervised examples
4274
4273
  texts = [m['input'] for m in self.learned_from_feedback]
@@ -4524,7 +4523,7 @@ class ExplainabilityModule:
4524
4523
 
4525
4524
  def _compute_anisotropy(self, attn_weights):
4526
4525
  if attn_weights is None or len(attn_weights) == 0:
4527
- return 0.5
4526
+ return self.pipeline.confidence_threshold
4528
4527
 
4529
4528
  try:
4530
4529
 
@@ -4538,7 +4537,7 @@ class ExplainabilityModule:
4538
4537
  return np.std(val) / (np.mean(val) + 1e-8)
4539
4538
 
4540
4539
  except:
4541
- return 0.5
4540
+ return self.pipeline.confidence_threshold
4542
4541
 
4543
4542
  def _compute_attention_quality(self, attn_weights):
4544
4543
  eps = 1e-5
@@ -4569,9 +4568,9 @@ class ExplainabilityModule:
4569
4568
 
4570
4569
  quality = norm_entropy * (1.0 - AMR) + avg_max * AMR + norm_var * AMR
4571
4570
  return np.clip(quality, 0, 1)
4572
- except:
4573
- print("[-] Error occurred while computing attention quality.")
4574
- AMR = 0.1
4571
+ except Exception as e:
4572
+ print(f"[-] Error occurred while computing attention quality: {e}")
4573
+ AMR = self.pipeline.confidence_threshold
4575
4574
  if attn_weights is not None:
4576
4575
  print(f"[-] Attention weights shape: {attn_weights.shape}")
4577
4576
  AME = self.AME_Encoder(attn_weights)
@@ -4681,19 +4680,19 @@ class ExplainabilityModule:
4681
4680
  d1 = self.decision_history[idx1]
4682
4681
  d2 = self.decision_history[idx2]
4683
4682
 
4684
- comparison.append(f"🔄 Decision Comparison")
4683
+ comparison.append(f"🔄 Ensemble Decision Comparison")
4685
4684
  comparison.append("====================================")
4686
4685
 
4687
- comparison.append("[<] Earlier Decision:")
4686
+ comparison.append("[<] Ensemble Earlier Decision:")
4688
4687
  comparison.append(f"[+] Input: {d1['input']}")
4689
4688
  comparison.append(f"[+] Detail Focus: {d1['prediction']} ({d1['confidence']:.1%})")
4690
4689
 
4691
- comparison.append("🧠 Later Decision:")
4690
+ comparison.append("🧠 Ensemble Later Decision:")
4692
4691
  comparison.append(f"[=] Input: {d2['input']}")
4693
4692
  comparison.append(f"[=] Detail Focus: {d2['prediction']} ({d2['confidence']:.1%})")
4694
4693
 
4695
- comparison.append("🔬 Learning Progress: ")
4696
- comparison.append(f"• Confidence {'increased' if d2['confidence'] > d1['confidence'] else 'decreased'} from {d1['confidence']} to {d2['confidence']}")
4694
+ comparison.append("🔬 Ensemble Learning Progress: ")
4695
+ comparison.append(f"• Confidence {'increased' if d2['confidence'] > d1['confidence'] else 'decreased'} from {d1['confidence']:.1%} to {d2['confidence']:.1%}")
4697
4696
  comparison.append(f"• The model is becoming {'more' if d2['confidence'] > d1['confidence'] else 'less'} certain")
4698
4697
 
4699
4698
  return '\n'.join(comparison)
@@ -4710,9 +4709,9 @@ class ExplainabilityModule:
4710
4709
 
4711
4710
  # Check transformer confidence
4712
4711
  if details['transformer']['confidence'] > 0.8:
4713
- factors.append(f"✅ Transformer is confident ({details['transformer']['confidence']}) with focused attention")
4712
+ factors.append(f"✅ Transformer is confident ({details['transformer']['confidence']:.1%}) with focused attention")
4714
4713
  elif details['transformer']['confidence'] < 0.5:
4715
- factors.append(f"🤔 Transformer is uncertain ({details['transformer']['confidence']}) due to scattered attention")
4714
+ factors.append(f"🤔 Transformer is uncertain with uncertainty up to: ({details['transformer']['confidence']:.1%}), due to scattered attention")
4716
4715
 
4717
4716
  # Check agreement
4718
4717
  if details['agreement']:
@@ -4722,9 +4721,9 @@ class ExplainabilityModule:
4722
4721
 
4723
4722
  # Attention quality
4724
4723
  if details.get('attention_quality', 0) > 0.7:
4725
- factors.append(f"[✅] High attention quality ({details['attention_quality']}) indicates clear consistent patterns!")
4724
+ factors.append(f"[✅] High attention quality: ({details['attention_quality']:.1%}) indicates clear consistent patterns!")
4726
4725
  elif details.get('attention_quality', 0) < 0.3:
4727
- factors.append(f"[-] Low Attention Quality! : ({details['attention_quality']}) Indicates noisy unnecessary patterns on seen data!")
4726
+ factors.append(f"[-] Low Attention Quality: ({details['attention_quality']:.1%}) Indicates inconsistent and ambiguous patterns on seen data!")
4728
4727
 
4729
4728
  return '\n'.join(factors)
4730
4729
 
@@ -9178,6 +9177,7 @@ class QueryNode:
9178
9177
 
9179
9178
  return self.permission
9180
9179
 
9180
+
9181
9181
  def _connect_with_peer(self, node):
9182
9182
  node_id = id(node)
9183
9183
 
@@ -9207,6 +9207,7 @@ class QueryNode:
9207
9207
 
9208
9208
  return self.permission
9209
9209
 
9210
+
9210
9211
  def _adjust_trust(self, node_id, delta):
9211
9212
  """
9212
9213
  trust that actually evolves. EMA-style bounded adjustment.
@@ -9215,6 +9216,7 @@ class QueryNode:
9215
9216
  updated = float(np.clip(current + delta, 0.0, 1.0))
9216
9217
  self._trust_scores[node_id] = updated
9217
9218
 
9219
+
9218
9220
  def _identify_node(self, node):
9219
9221
  eps = 1e-5
9220
9222
  node_id = id(node)
@@ -9238,6 +9240,7 @@ class QueryNode:
9238
9240
  ) + eps
9239
9241
  return False
9240
9242
 
9243
+
9241
9244
  def _node_safety_check(self, node):
9242
9245
  node_id = id(node)
9243
9246
  trust = self._trust_scores.get(node_id, self._default_trust)
@@ -9541,6 +9544,10 @@ class IntegratedPipeline:
9541
9544
  self.lstm_lr = 5e-2
9542
9545
  self.lstm_hidden_dim = 64
9543
9546
 
9547
+ self.unsuitable_tolerance = False
9548
+ self.unsuitable_conditions = False
9549
+ self.unsuitable_peer_request = False
9550
+
9544
9551
  # Main component setup
9545
9552
  self.standard_scaler = StandardScaler()
9546
9553
  self.tfidf = TfidfVectorizer(max_features=70)
@@ -12093,9 +12100,18 @@ class IntegratedPipeline:
12093
12100
  if 0 <= mlp_target < n_classes and i < calibrated.shape[0]:
12094
12101
  if mlp_target_int is None:
12095
12102
  mlp_target_int = int(mlp_target.flat[0])
12096
- calibrated[i, mlp_target_int] = min(
12097
- calibrated[i, mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12098
- )
12103
+
12104
+ if len(calibrated.shape) >= 2:
12105
+ calibrated[i, mlp_target_int] = min(
12106
+ calibrated[i, mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12107
+ )
12108
+ else:
12109
+ if mlp_target_int < len(calibrated):
12110
+ calibrated[mlp_target_int] = min(
12111
+ calibrated[mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12112
+ )
12113
+ else:
12114
+ calibrated = min(calibrated * (1.5 * (1.0 - abstract_score)), 0.95)
12099
12115
 
12100
12116
  if i <= len(calibrated):
12101
12117
  try:
@@ -12504,7 +12520,7 @@ class IntegratedPipeline:
12504
12520
  lengths.add(1)
12505
12521
 
12506
12522
  if len(lengths) > 1:
12507
- # RAGGED — pad to uniform length
12523
+ # RAGGED — pad to uniform length.
12508
12524
  max_len = max(lengths)
12509
12525
  print(f'[=] AME_Encoder: ragged input detected '
12510
12526
  f'(lengths: {lengths}) — padding to {max_len}')
@@ -13077,6 +13093,10 @@ class IntegratedPipeline:
13077
13093
  unsuitable_training = False
13078
13094
 
13079
13095
  probs = self.model_memory_gate(input_ids, x)
13096
+ cache = self.accurate_cache_lookup.lookup(
13097
+ x_mlp=x,
13098
+ input_ids=input_ids)
13099
+ cached = cache is not None and cache['similarity'] >= 0.95
13080
13100
 
13081
13101
  anisotropy = self.anisotropy_measurement(input_ids)
13082
13102
  AME = self.AME_Encoder(input_ids)
@@ -13095,11 +13115,15 @@ class IntegratedPipeline:
13095
13115
  # AMR is guaranteed to give sufficient ratio on how modelling error error could be sufficient enough to guarantee the model successful training
13096
13116
  # (not too high that it shows unstability, not too low that it shows rigidity), high anisotropy correlates to a much complex non linearity that the model will have a hard time adjusting
13097
13117
  # Too high AAC means the model is likely to be in a regime where training could lead to overfitting or divergence due to insufficient modelling capacity relative to the complexity of the data, especially if the confidence score is also low, indicating that the model is not currently confident in its predictions and may not benefit from further training on this data.
13098
- unsuitable_tolerance = probs is not None or AAC > 0.75
13118
+ unsuitable_tolerance = probs is not None and cached or AAC > 0.75
13099
13119
  unsuitable_conditions = anisotropy > 0.85 or final_conf > confidence_threshold or self.froze_learning
13100
13120
  unsuitable_peer_request = probs is not None and self.peer_assistance_threshold > self.confidence_threshold
13101
13121
 
13102
- if unsuitable_tolerance or unsuitable_conditions or unsuitable_peer_request:
13122
+ self.unsuitable_tolerance = unsuitable_tolerance
13123
+ self.unsuitable_conditions = unsuitable_conditions
13124
+ self.unsuitable_peer_request = unsuitable_peer_request
13125
+
13126
+ if self.unsuitable_tolerance or self.unsuitable_conditions or self.unsuitable_peer_request:
13103
13127
  print(f'[==] Unsuitable training condition detected! Tolerance: {unsuitable_tolerance} || Unsuitable Conditions: {unsuitable_conditions}')
13104
13128
  print(f'[==] Peer assistance condition: {unsuitable_peer_request} || Peer assistance threshold: {self.peer_assistance_threshold}')
13105
13129
  unsuitable_training = True
@@ -13165,6 +13189,8 @@ class IntegratedPipeline:
13165
13189
  if sequence_inputs.shape[1] == 1:
13166
13190
  print('[=] transformer_pooled_features: single-timestep input, '
13167
13191
  'std_pool will be all zeros (no variance across T=1)')
13192
+ print('[=] Reshaping sequence inputs to 2 dimension...')
13193
+ sequence_inputs = sequence_inputs.reshape(-1, 1)
13168
13194
 
13169
13195
  mean_pool = np.mean(sequence_inputs, axis=1)
13170
13196
  max_pool = np.max(sequence_inputs, axis=1)
@@ -13323,7 +13349,7 @@ class IntegratedPipeline:
13323
13349
  )
13324
13350
 
13325
13351
  if issues:
13326
- print(f"[WARNING] [{context}] y_true failed one-hot validation, one-hot encoding y sample...")
13352
+ print(f"[>] [{context}] y_true failed one-hot validation, one-hot encoding y sample...")
13327
13353
  return True
13328
13354
 
13329
13355
  return False
@@ -13434,7 +13460,7 @@ class IntegratedPipeline:
13434
13460
  weak_rows = np.where(row_sums < min_signal)[0]
13435
13461
  weak_ratio = len(weak_rows) / len(X_raw_features)
13436
13462
 
13437
- print(f'[!] Zero ratio in samples: {weak_ratio * 100}%')
13463
+ print(f'[>] Zero ratio in samples: {weak_ratio * 100}%')
13438
13464
  if weak_ratio > 0.3: # more than 30% zero rows means vocab mismatch
13439
13465
  if isinstance(X_raw_generation[0], str):
13440
13466
  print(f'[= ! =] High zero-row ratio ({weak_ratio:.0%}), refitting on current batch')
@@ -13518,7 +13544,7 @@ class IntegratedPipeline:
13518
13544
  print('🎉 All Model Trained!')
13519
13545
  else:
13520
13546
  print(f'[=] No suitable condition for training!')
13521
- print('[=] Saving Weights for prediction')
13547
+ print('[>] Loading Weights for prediction...')
13522
13548
 
13523
13549
  num_classes = self._get_num_classes(label_map=label_map) if label_map else (y_true.shape[1] if y_true.ndim > 1 else len(np.unique(y_true)))
13524
13550
 
@@ -17162,6 +17188,42 @@ class PipelinePredictionManager:
17162
17188
 
17163
17189
  return X_train, X_val, y_train, y_val
17164
17190
 
17191
+ def _compute_need_ensemble_method(self, anisotropy, AME, error_counts,
17192
+ anisotropy_threshold=0.3,
17193
+ ame_threshold=0.3,
17194
+ error_threshold=0.3,
17195
+ min_signals_required=1):
17196
+ """
17197
+ Ensemble fallback is a safety net — it should trigger if ANY
17198
+ single strong risk signal fires, not only when all signals
17199
+ happen to align simultaneously. Uses max() over error_counts
17200
+ so a single persistently-wrong class triggers assistance even
17201
+ when most other classes are healthy.
17202
+ """
17203
+ signals = []
17204
+
17205
+ if anisotropy is not None and anisotropy > anisotropy_threshold:
17206
+ signals.append(f'anisotropy={anisotropy:.3f}')
17207
+
17208
+ if AME is not None and AME > ame_threshold:
17209
+ signals.append(f'AME={AME:.3f}')
17210
+
17211
+ if error_counts is not None and len(error_counts) > 0:
17212
+ # FIX — max, not mean: catches localized single-class failure
17213
+ # that a flat average would dilute away
17214
+ worst_class_idx = int(np.argmax(error_counts))
17215
+ max_error = float(error_counts[worst_class_idx])
17216
+ if max_error > error_threshold:
17217
+ signals.append(f'error_rate(class={worst_class_idx}, '
17218
+ f'value={max_error:.2f})')
17219
+
17220
+ need_ensemble = len(signals) >= min_signals_required
17221
+
17222
+ if need_ensemble:
17223
+ print(f'[=] Ensemble method triggered by: {", ".join(signals)}')
17224
+
17225
+ return need_ensemble
17226
+
17165
17227
  def advanced_prediction_method(self, titles=None, label_map=None, rules=None,
17166
17228
  X=None, y=None,
17167
17229
  show_proba=False, top_k=3,
@@ -17190,6 +17252,7 @@ class PipelinePredictionManager:
17190
17252
  X_gen = None
17191
17253
  sec_chosen_label = None
17192
17254
  sec_confidence = 0.0
17255
+ final_confidence = 0.0
17193
17256
 
17194
17257
  correct = 0
17195
17258
  sec_correct= 0
@@ -17234,7 +17297,7 @@ class PipelinePredictionManager:
17234
17297
 
17235
17298
  if 0 in X.shape:
17236
17299
  print(f"[⚠️] Warning: X has zero samples in the total shapes, X shapes: {X.shape}. Creating an empty array with shape (1, n_features) for processing..")
17237
- X = np.empty((1, X.shape[1])) # Create an empty array with shape (1, n_features)
17300
+ X = np.empty((1, X.shape[1])) # Created an empty array with shape (1, n_features)
17238
17301
  X = X.reshape(1, -1) # Reshape to (1, n_features) if empty but has features
17239
17302
 
17240
17303
  X_train, X_val, y_train, y_val = self._prepare_train_val_split(
@@ -17371,7 +17434,7 @@ class PipelinePredictionManager:
17371
17434
  if hasattr(self.pipeline.mlp, 'predict_proba'):
17372
17435
  mlp_probs = self.pipeline.model3.predict_proba(X)
17373
17436
  else:
17374
- logits = self.pipeline.mlp.forward(X)
17437
+ logits = self.pipeline.model3.forward(X)
17375
17438
  mlp_probs = self.pipeline._softmax(logits)
17376
17439
 
17377
17440
  # Validate all MLP predictions at once
@@ -17393,7 +17456,6 @@ class PipelinePredictionManager:
17393
17456
  if sequence_ids is not None:
17394
17457
  print("\n[🔍] Using sequence encoding for transformer input due to low anisotropy.")
17395
17458
  input_ids = sequence_ids.copy()
17396
-
17397
17459
  # verify samples for accurate answer from cache
17398
17460
  print('[🔍] Verifying Samples for possible predicted output in cache for accurate answer...')
17399
17461
  cached = self.pipeline.accurate_cache_lookup.lookup(
@@ -17439,12 +17501,13 @@ class PipelinePredictionManager:
17439
17501
  else:
17440
17502
  lstm_probs = None
17441
17503
 
17442
- need_ensemble_method = (
17443
- anisotropy > 0.3 and
17444
- AME is not None and
17445
- AME > 0.3 and
17446
- np.mean(self.error_counts) > 0.3
17447
- )
17504
+
17505
+ threshold = 0.5 + (self.pipeline.confidence_threshold + np.mean(self.error_counts)) / 2
17506
+ need_ensemble_method = self._compute_need_ensemble_method(anisotropy, AME, self.error_counts,
17507
+ anisotropy_threshold=threshold,
17508
+ ame_threshold=threshold,
17509
+ error_threshold=threshold,
17510
+ min_signals_required=1)
17448
17511
 
17449
17512
  results = []
17450
17513
  attention_data = [] if return_attention else None
@@ -17757,7 +17820,7 @@ class PipelinePredictionManager:
17757
17820
  if not results[0].get('models_agree', True) and self.pipeline.use_transformer:
17758
17821
  trans_confidence = results[0].get('trans_confidence', 1e-8)
17759
17822
  confidence = (confidence + trans_confidence / 2) + 1e-5
17760
- print(f'[=] Calibrating confidence around: {confidence:.1%} Due to disagreement between Transformer and MLP.')
17823
+ print(f'[=] Calibrating confidence around: {confidence:.1%}')
17761
17824
 
17762
17825
  if isinstance(chosen_label, str) and chosen_label.startswith("unknown") or float(confidence) < self.pipeline.confidence_threshold:
17763
17826
  if chosen_label is None or chosen_label.startswith('unknown'):
@@ -18034,7 +18097,7 @@ class PipelinePredictionManager:
18034
18097
  print(f"[!] Error in advanced prediction method: {e}, Initiating regular prediction method...")
18035
18098
  traceback.print_exc()
18036
18099
  try:
18037
- results = self.regular_prediction_method(titles=titles, label_map=label_map, rules=rules, X=X, y=y, show_proba=False, top_k=3, batch_size=2, use_transformer=True)
18100
+ results = self.regular_prediction_method(titles=titles, label_map=label_map, rules=rules, X=X, y=y, show_proba=False, top_k=3, batch_size=2, use_transformer=self.pipeline.use_transformer)
18038
18101
  chosen_label = results[0]['predicted']
18039
18102
  confidence = results[0]['confidence']
18040
18103
  except Exception as error:
@@ -18075,7 +18138,7 @@ class PipelinePredictionManager:
18075
18138
  self.pred_counts *= decay
18076
18139
 
18077
18140
  if final_probs is None:
18078
- print('[!] Warning final probabilities is None! returning the probabilities...')
18141
+ print('[!] Warning final probabilities is None! returning the None probabilities...')
18079
18142
  return final_probs
18080
18143
 
18081
18144
  try:
@@ -18109,12 +18172,15 @@ class PipelinePredictionManager:
18109
18172
  prob_sum = final_probs.sum()
18110
18173
  if prob_sum > 1e-8:
18111
18174
  final_probs /= prob_sum
18112
-
18175
+
18113
18176
  # re adapt shape of pred_counts and error_counts if they don't match prob shape
18114
18177
  if self.pred_counts.shape != final_probs.shape:
18115
18178
  self.pred_counts = np.zeros_like(final_probs)
18179
+ self.pred_counts *= decay
18116
18180
  if self.error_counts.shape != final_probs.shape:
18117
18181
  self.error_counts = np.zeros_like(final_probs)
18182
+ self.error_counts *= decay
18183
+
18118
18184
 
18119
18185
  except Exception as e:
18120
18186
  print(f'[!] Cant check and calibrate probs based on penalty due to: {e}')