@@ -74,10 +74,11 @@ def read_mat(path, label, load):
7474 for size , label in size_map .items ():
7575 dir_path = os .path .join (fault_dir , ftype , size )
7676 if not os .path .exists (dir_path ): continue
77- for f in os .listdir (dir_path ):
78- if f .endswith ('.mat' ):
79- load = int (f .split ('_' )[- 1 ].split ('.' )[0 ])
80- read_mat (os .path .join (dir_path , f ), label , load )
77+ for root , dirs , files in os .walk (dir_path ):
78+ for f in files :
79+ if f .endswith ('.mat' ):
80+ load = int (f .split ('_' )[- 1 ].split ('.' )[0 ])
81+ read_mat (os .path .join (root , f ), label , load )
8182
8283 return np .array (X , dtype = np .float32 ), np .array (y ), np .array (cond )
8384
@@ -174,9 +175,19 @@ def main():
174175 'Run: pip install dowhy' )
175176
176177 # 7. example auditable diagnoses
177- print ('\n [examples] auditable root-cause diagnoses:' )
178- for r in report .records [:5 ]:
179- print (f' [{ r ["status" ]} ] { r ["root_cause" ]["statement" ]} ' )
178+ print ('\n [examples] auditable root-cause diagnoses (CONFIRMED faults only):' )
179+ seen_classes = set ()
180+ examples = []
181+ for idx , r in enumerate (report .records ):
182+ y_true = test_data .y [idx ]
183+ if r ["physics_verdict" ] == "CONFIRMED" and y_true > 0 :
184+ if y_true not in seen_classes :
185+ examples .append (f' [Class { y_true } ] [{ r ["status" ]} ] { r ["root_cause" ]["statement" ]} ' )
186+ seen_classes .add (y_true )
187+ if len (examples ) >= 5 :
188+ break
189+ for ex in examples :
190+ print (ex )
180191
181192 print ('\n ' + '=' * 68 )
182193 print ('VALIDATION COMPLETE - if all sections printed, the pipeline runs '
0 commit comments