26 """Test that human inputs are treated as ground truth"""
27 logger.info(
"=== Testing Human Input as Ground Truth ===")
30 system = MultivariateBayesianCalibration(num_sensors=2, order=3)
33 logger.info(
"\n--- Test 1: Human Input (Ground Truth) ---")
34 human_point = CalibrationPoint(
38 environmental_state=EnvironmentalState(),
41 human_point.is_human_input =
True
43 system.multivariate_calibration_update(0, human_point)
45 logger.info(f
"After 1 human input:")
46 logger.info(f
" PT0 autonomy: {system.autonomy_levels[0]:.3f}")
47 logger.info(f
" PT0 confidence: {system.confidence_scores[0]:.3f}")
48 logger.info(f
" Consensus confidence: {system.consensus_confidence:.3f}")
49 logger.info(f
" Population strength: {system.population_strength:.3f}")
52 logger.info(
"\n--- Test 2: Multiple Human Inputs ---")
53 for i, (v, p)
in enumerate([(0.6, 50), (0.7, 100), (0.8, 200)]):
54 human_point = CalibrationPoint(
58 environmental_state=EnvironmentalState(),
61 human_point.is_human_input =
True
63 system.multivariate_calibration_update(0, human_point)
65 logger.info(f
"After {i+2} human inputs:")
66 logger.info(f
" PT0 autonomy: {system.autonomy_levels[0]:.3f}")
67 logger.info(f
" PT0 confidence: {system.confidence_scores[0]:.3f}")
68 logger.info(f
" Consensus confidence: {system.consensus_confidence:.3f}")
71 logger.info(
"\n--- Test 3: Consensus Input (Auto-detected) ---")
72 consensus_point = CalibrationPoint(
76 environmental_state=EnvironmentalState(),
79 consensus_point.is_consensus =
True
81 system.multivariate_calibration_update(0, consensus_point)
83 logger.info(f
"After 1 consensus input:")
84 logger.info(f
" PT0 autonomy: {system.autonomy_levels[0]:.3f}")
85 logger.info(f
" PT0 confidence: {system.confidence_scores[0]:.3f}")
86 logger.info(f
" Consensus confidence: {system.consensus_confidence:.3f}")
89 logger.info(
"\n--- Test 4: PT1 with Human Inputs (Population Learning) ---")
90 for i, (v, p)
in enumerate([(0.52, 0), (0.62, 50), (0.72, 100)]):
91 human_point = CalibrationPoint(
95 environmental_state=EnvironmentalState(),
98 human_point.is_human_input =
True
100 system.multivariate_calibration_update(1, human_point)
102 logger.info(f
"After {i+1} human inputs on PT1:")
103 logger.info(f
" PT1 autonomy: {system.autonomy_levels[1]:.3f}")
104 logger.info(f
" PT1 confidence: {system.confidence_scores[1]:.3f}")
105 logger.info(f
" Consensus confidence: {system.consensus_confidence:.3f}")
106 logger.info(f
" Population strength: {system.population_strength:.3f}")
109 logger.info(
"\n--- Final Results ---")
111 f
"PT0 - Autonomy: {system.autonomy_levels[0]:.3f}, Confidence: {system.confidence_scores[0]:.3f}"
114 f
"PT1 - Autonomy: {system.autonomy_levels[1]:.3f}, Confidence: {system.confidence_scores[1]:.3f}"
116 logger.info(f
"System - Consensus Confidence: {system.consensus_confidence:.3f}")
117 logger.info(f
"System - Population Strength: {system.population_strength:.3f}")
125 expected_pt0_autonomy = 4 * 0.5
126 expected_pt0_confidence = 4 * 0.4
127 expected_consensus = 7 * 0.15
129 logger.info(f
"\nExpected vs Actual:")
131 f
"PT0 Autonomy: Expected ~{expected_pt0_autonomy:.1f}, Actual {system.autonomy_levels[0]:.3f}"
134 f
"PT0 Confidence: Expected ~{expected_pt0_confidence:.1f}, Actual {system.confidence_scores[0]:.3f}"
137 f
"Consensus Confidence: Expected ~{expected_consensus:.1f}, Actual {system.consensus_confidence:.3f}"
142 if system.autonomy_levels[0] < 0.5:
143 logger.error(f
"PT0 autonomy too low: {system.autonomy_levels[0]:.3f} < 0.5")
146 logger.info(f
"✅ PT0 autonomy good: {system.autonomy_levels[0]:.3f}")
148 if system.confidence_scores[0] < 0.5:
149 logger.error(f
"PT0 confidence too low: {system.confidence_scores[0]:.3f} < 0.5")
152 logger.info(f
"✅ PT0 confidence good: {system.confidence_scores[0]:.3f}")
154 if system.consensus_confidence < 0.4:
156 f
"Consensus confidence too low: {system.consensus_confidence:.3f} < 0.4"
160 logger.info(f
"✅ Consensus confidence good: {system.consensus_confidence:.3f}")
162 if system.population_strength < 0.8:
164 f
"Population strength too low: {system.population_strength:.3f} < 0.8"
168 logger.info(f
"✅ Population strength good: {system.population_strength:.3f}")
172 "✅ All tests passed! Human inputs properly treated as ground truth."
175 logger.error(
"❌ Tests failed! System not properly adapting to human inputs.")