数据质量检查与汇总统计

Python 中的机器学习监控

Hakim Elakhrass

Co-founder and CEO of NannyML

什么是数据质量检查与汇总统计?

图示监控流程,在自动根因分析步骤中高亮了数据质量检查与汇总统计。

  • 缺失值检测
  • 未见值检测
  • 求和、均值、标准差、中位数与行计数
Python 中的机器学习监控

缺失值检测

  • 分块内观测数减少
  • 关键信息丢失
  • 产生错误解读与决策
# Instantiate the missing values calculator module
ms_calc = nannyml.MissingValuesCalculator(column_names=["Age"], normalize=True)

# Fit the calculator on the reference set
ms_calc.fit(reference)

# Calculate the rate of the missing values on the analysis set
ms_results = ms_calc.calculate(analysis)
ms_results.plot()
Python 中的机器学习监控

缺失值图

该图展示 normalize 参数设为 True 与 False 时的缺失值结果对比。

Python 中的机器学习监控

未见值检测

  • 参考期中未出现的分类特征取值
  • 未见值增多会降低模型在部分区域的置信度
# Instantiate the unseen values calculator module
us_calc = nannyml.UnseenValuesCalculator(column_names=["Cabin"], normalize=False)
# Fit, calculate and plot the rate of the unseen values
us_calc.fit(reference)
us_results = us_calc.calculate(analysis)
us_results.plot()

该图展示未见值随时间变化的曲线。

Python 中的机器学习监控

汇总统计

  • 求和:用于财务数据计算某段时间的收入或利润。
  • 均值标准差:用于数据漂移检查与可解释性。
  • 中位数:对离群值不敏感,适合含极值较多的特征。
  • 行计数:判断每个分块的数据量是否充足。
sum_calc = nannyml.SummaryStatsSumCalculator(column_names=selected_columns)
avg_calc = nannyml.SummaryStatsAvgCalculator(column_names=selected_columns)
std_calc = nannyml.SummaryStatsStdCalculator(column_names=selected_columns)
med_calc = nannyml.SummaryStatsMedianCalculator(column_names=selected_columns)
rows_calc = nannyml.SummaryStatsRowCountCalculator(column_names=selected_columns)
Python 中的机器学习监控

开始练习!

Python 中的机器学习监控

Preparing Video For Download...