FLEX: fixing flaky tests in machine learning projects by updating assertion bounds
Authors:
Open Access
- 18 August 2021
- conference paper
- Published by Association for Computing Machinery (ACM)
- p. 603-614
Abstract
Many machine learning (ML) algorithms are inherently random – multiple executions using the same inputs may produce slightly different results each time. Randomness impacts how developers write tests that check for end-to-end quality of their implementations of these ML algorithms. In particular, selecting the proper thresholds for comparing obtained quality metrics with the reference results is a non-intuitive task, which may lead to flaky test executions. We present FLEX, the first tool for automatically fixing flaky tests due to algorithmic randomness in ML algorithms. FLEX fixes tests that use approximate assertions to compare actual and expected values that represent the quality of the outputs of ML algorithms. We present a technique for systematically identifying the acceptable bound between the actual and expected output quality that also minimizes flakiness. Our technique is based on the Peak Over Threshold method from statistical Extreme Value Theory, which estimates the tail distribution of the output values observed from several runs. Based on the tail distribution, FLEX updates the bound used in the test, or selects the number of test re-runs, based on a desired confidence level. We evaluate FLEX on a corpus of 35 tests collected from the latest versions of 21 ML projects. Overall, FLEX identifies and proposes a fix for 28 tests. We sent 19 pull requests, each fixing one test, to the developers. So far, 9 have been accepted by the developers.Keywords
Funding Information
- Microsoft
- NSF (National Science Foundation) (CCF-1846354,CCF-1956374,CCF-2008883,CCF-2028861)
This publication has 28 references indexed in Scilit:
- AutoSense: A Framework for Automated Sensitivity Analysis of Program DataIEEE Transactions on Software Engineering, 2017
- Probabilistic programming in Python using PyMC3PeerJ Preprints, 2016
- Probabilistic programming2014
- Supporting Test Suite Evolution through Test Case Adaptation2012
- Specification-Based Test Repair Using a Lightweight Formal MethodLecture Notes in Computer Science, 2012
- Box–Cox transformations and heavy-tailed distributionsJournal of Applied Probability, 2004
- Tutorial on maximum likelihood estimationJournal of Mathematical Psychology, 2003
- Goodness-of-Fit Tests for the Generalized Pareto DistributionTechnometrics, 2001
- Likelihood Ratio Test, Wald Test, and Kuhn-Tucker Test in Linear Models with Inequality Constraints on the Regression ParametersEconometrica, 1982
- Limit Distributions for Order Statistics. ITheory of Probability & Its Applications, 1978