feat(pre_processing.py): 启用异常值检测图表生成
remove_outliers() 函数: - 原代码: fig = None # plotting disabled - 修复: 调用 plotting.outliers(df, column, name) 生成箱线图, 显示 IQR 方法的异常值检测结果 异常保护:try/except 包裹,绘图失败时回退至 None
This commit is contained in:
@ -129,7 +129,11 @@ def remove_outliers(df: pd.DataFrame, column: str, name: str):
|
|||||||
fence_low = q1 - 3 * iqr
|
fence_low = q1 - 3 * iqr
|
||||||
fence_high = q3 + 3 * iqr
|
fence_high = q3 + 3 * iqr
|
||||||
|
|
||||||
fig = None # plotting disabled
|
try:
|
||||||
|
from . import plotting
|
||||||
|
fig = plotting.outliers(df, column, name)
|
||||||
|
except Exception:
|
||||||
|
fig = None
|
||||||
|
|
||||||
outliers = df.loc[(df[column] < fence_low) | (df[column] > fence_high)]
|
outliers = df.loc[(df[column] < fence_low) | (df[column] > fence_high)]
|
||||||
if len(outliers) > 0:
|
if len(outliers) > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user