arXiv:2509.11748cs.SEcs.LG2025-09

用多层级分析工具提升机器学习笔记本代码质量

Analysing Python Machine Learning Notebooks with Moose

  • 基于元建模技术统一分析代码、结构和机器学习特性
  • 在5000个Kaggle笔记本中发现三类问题普遍存在
  • 适合关注ML代码可复现性与工程规范的开发者

机器学习代码,尤其是笔记本文档,通常质量低于传统软件。不良实践出现在三个层面:通用Python编码规范、笔记本文档的组织结构,以及机器学习特有方面如可复现性和正确API使用。然而现有分析工具通常仅聚焦单一层面,难以捕捉机器学习语义,限制了问题检测能力。本文提出Vespucci Linter,一种基于Moose构建的多层级静态分析工具,采用元建模方法将笔记本文档结构元素与Python代码实体统一建模,实现更上下文相关的分析。我们基于文献设计了22条检查规则,并在来自Kaggle平台的5000个笔记本上应用该工具。结果表明三类问题均广泛存在,验证了多层级方法的有效性,展示了Vespucci Linter在提升机器学习开发环境代码质量和可靠性方面的潜力。

原文摘要 · Abstract (English)

Machine Learning (ML) code, particularly within notebooks, often exhibits lower quality compared to traditional software. Bad practices arise at three distinct levels: general Python coding conventions, the organizational structure of the notebook itself, and ML-specific aspects such as reproducibility and correct API usage. However, existing analysis tools typically focus on only one of these levels and struggle to capture ML-specific semantics, limiting their ability to detect issues. This paper introduces Vespucci Linter, a static analysis tool with multi-level capabilities, built on Moose and designed to address this challenge. Leveraging a metamodeling approach that unifies the notebook's structural elements with Python code entities, our linter enables a more contextualized analysis to identify issues across all three levels. We implemented 22 linting rules derived from the literature and applied our tool to a corpus of 5,000 notebooks from the Kaggle platform. The results reveal violations at all levels, validating the relevance of our multi-level approach and demonstrating Vespucci Linter's potential to improve the quality and reliability of ML development in notebook environments.

代码质量静态分析机器学习

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。