@@ -2348,9 +2348,7 @@ async def handle_call_tool(
23482348
23492349 if result and len (result ) > 0 :
23502350 stats = result [0 ]
2351- correlation = stats .get ('correlation' , 0.0 )
2352- if correlation is None :
2353- correlation = 0.0
2351+ correlation = stats ['correlation' ] if 'correlation' in stats .keys () and stats ['correlation' ] is not None else 0.0
23542352
23552353 # Interpret correlation strength
23562354 if abs (correlation ) >= 0.9 :
@@ -2368,7 +2366,7 @@ async def handle_call_tool(
23682366
23692367 output = f"""Correlation Analysis between { column_x } and { column_y } :
23702368
2371- Sample Size: { stats ['count ' ]:,}
2369+ Sample Size: { stats ['n ' ]:,}
23722370Mean { column_x } : { stats ['mean_x' ]:.4f}
23732371Mean { column_y } : { stats ['mean_y' ]:.4f}
23742372
@@ -2484,11 +2482,12 @@ async def handle_call_tool(
24842482 """
24852483
24862484 iqr_result = db ._execute_query (iqr_query )
2487- if iqr_result :
2485+ if iqr_result and len (iqr_result ) > 0 :
2486+ row = iqr_result [0 ]
24882487 outliers_found .append (f"IQR Method (multiplier={ iqr_multiplier } ):" )
2489- outliers_found .append (f" Lower bound: { iqr_result [ 0 ] ['lower_bound' ]:.4f} " )
2490- outliers_found .append (f" Upper bound: { iqr_result [ 0 ] ['upper_bound' ]:.4f} " )
2491- outliers_found .append (f" Outliers found: { iqr_result [ 0 ] ['iqr_outliers' ]} " )
2488+ outliers_found .append (f" Lower bound: { row ['lower_bound' ]:.4f} " )
2489+ outliers_found .append (f" Upper bound: { row ['upper_bound' ]:.4f} " )
2490+ outliers_found .append (f" Outliers found: { row ['iqr_outliers' ]} " )
24922491
24932492 if method in ["zscore" , "both" ]:
24942493 # Z-score method
@@ -2515,10 +2514,11 @@ async def handle_call_tool(
25152514
25162515 zscore_result = db ._execute_query (zscore_query )
25172516 if zscore_result and len (zscore_result ) > 0 :
2517+ row = zscore_result [0 ]
25182518 outliers_found .append (f"\n Z-Score Method (threshold={ zscore_threshold } ):" )
2519- outliers_found .append (f" Lower bound: { zscore_result [ 0 ] ['lower_bound' ]:.4f} " )
2520- outliers_found .append (f" Upper bound: { zscore_result [ 0 ] ['upper_bound' ]:.4f} " )
2521- outliers_found .append (f" Outliers found: { zscore_result [ 0 ] ['zscore_outliers' ]} " )
2519+ outliers_found .append (f" Lower bound: { row ['lower_bound' ]:.4f} " )
2520+ outliers_found .append (f" Upper bound: { row ['upper_bound' ]:.4f} " )
2521+ outliers_found .append (f" Outliers found: { row ['zscore_outliers' ]} " )
25222522 else :
25232523 outliers_found .append (f"\n Z-Score Method (threshold={ zscore_threshold } ):" )
25242524 outliers_found .append (f" Outliers found: 0" )
@@ -2629,9 +2629,9 @@ async def handle_call_tool(
26292629
26302630 result = db ._execute_query (dist_query )
26312631
2632- if result :
2632+ if result and len ( result ) > 0 :
26332633 stats = result [0 ]
2634- frequencies = stats ['frequencies' ].split (',' ) if stats ['frequencies' ] else []
2634+ frequencies = stats ['frequencies' ].split (',' ) if stats ['frequencies' ] and stats [ 'frequencies' ] is not None else []
26352635
26362636 output = f"""Distribution Analysis for { table_name } .{ column_name } :
26372637
@@ -2704,7 +2704,7 @@ async def handle_call_tool(
27042704
27052705 result = db ._execute_query (regression_query )
27062706
2707- if result :
2707+ if result and len ( result ) > 0 :
27082708 reg = result [0 ]
27092709 r_squared = reg ['r_value' ] ** 2 if reg ['r_value' ] is not None else 0
27102710
@@ -2770,7 +2770,7 @@ async def handle_call_tool(
27702770
27712771 result = db ._execute_query (test_query )
27722772
2773- if result :
2773+ if result and len ( result ) > 0 :
27742774 test_result = result [0 ]
27752775
27762776 # Critical t-value approximation (for common cases)
0 commit comments