|
|
@@ -18,6 +18,7 @@ from sklearn.cluster import DBSCAN
|
|
|
from sklearn.decomposition import PCA
|
|
|
from sklearn.preprocessing import StandardScaler
|
|
|
from defect_analysis.data_quality import build_data_quality_report
|
|
|
+from defect_analysis.ml.key_factors import find_key_factors
|
|
|
from app_utils import (
|
|
|
apply_defect_filters,
|
|
|
build_diagnostic_dashboard,
|
|
|
@@ -298,6 +299,7 @@ if _t:
|
|
|
dashboard = build_diagnostic_dashboard(filtered_df)
|
|
|
industry_diagnosis = generate_industry_diagnosis(filtered_df, dashboard)
|
|
|
quality_report = build_data_quality_report(filtered_df)
|
|
|
+ key_factors = find_key_factors(filtered_df, target_defect_type=dashboard["top_defect_type"], top_n=10)
|
|
|
level_colors = {
|
|
|
"严重": ("#7f1d1d", "#fee2e2"),
|
|
|
"关注": ("#92400e", "#fef3c7"),
|
|
|
@@ -559,6 +561,16 @@ if _t:
|
|
|
st.dataframe(extended_table, use_container_width=True, hide_index=True)
|
|
|
st.caption("覆盖治具、吸嘴、材料批次、清洗/绑定等维度,用于多前制程链路追溯。")
|
|
|
|
|
|
+ if not key_factors.empty:
|
|
|
+ st.subheader(f"关键因子分析:{dashboard['top_defect_type']}")
|
|
|
+ key_factor_table = key_factors.copy()
|
|
|
+ key_factor_table["目标占比"] = key_factor_table["目标占比"].map(lambda v: f"{v:.1%}")
|
|
|
+ key_factor_table["基线占比"] = key_factor_table["基线占比"].map(lambda v: f"{v:.1%}")
|
|
|
+ key_factor_table["异常倍数"] = key_factor_table["异常倍数"].map(lambda v: f"{v:.2f}x")
|
|
|
+ key_factor_table["支持度"] = key_factor_table["支持度"].map(lambda v: f"{v:.1%}")
|
|
|
+ st.dataframe(key_factor_table, use_container_width=True, hide_index=True)
|
|
|
+ st.caption("关键因子按目标缺陷占比、异常倍数、样本数和支持度综合排序。")
|
|
|
+
|
|
|
trend_col, pareto_col = st.columns([1, 1])
|
|
|
with trend_col:
|
|
|
st.subheader("每日缺陷走势")
|