machine learning testing [email protected] jie m. zhang ... - … · definitions of machine...

43
Machine Learning Testing Jie M. Zhang, CREST, UCL [email protected]

Upload: others

Post on 19-Jul-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Machine Learning TestingJie M. Zhang, CREST, UCL

[email protected]

Page 2: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

About me

Research Fellow at CREST, UCL

Supervisor: Prof. Mark Harman

PHD student of Peking University | Sep, 2015

– June, 2018 | Supervisor : Lu Zhang

Research Interest

https://sites.google.com/view/jie-zhang/home

Page 3: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Why SE ML Matters?

Diversity Matters Different communities: different perspectives

Page 4: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

What Can SE Bring to ML?

ML Community

Page 5: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

What Can SE Bring to ML?

ML Community

“Analysis destroys wholes. Some things, magic things, are meant to stay whole. If you look at their pieces, they go away.” -- The Bridges of Madison County

Page 6: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

What Can SE Bring to ML?

ML Community

SE Community

Page 7: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

SE for ML: Where are we now?

ML Community

Page 8: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

SE for ML: Can we take another path?

SE Community

ML Community

Page 9: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 10: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Number of ML testing publications

trustworthiness

Page 11: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Number of ML testing publications

Page 12: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Definitions of Machine Learning Testing

An ML bug refers to any imperfection in a

machine learning item that causes a discordance between the

existing and the required conditions.

Definition 1 (ML Bug).

Machine Learning Testing (ML testing) refers

to any activities designed to reveal machine learning bugs

Definition 2 (ML Testing).

Page 13: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Comparison between ML testing & software testing

Page 14: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Comparison between ML testing & software testing

Page 15: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Comparison between ML Testing & Software Testing

“There would be no need to write such programs, if the correct answer were known”------- Davis and Weyuker, 1981

Page 16: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Definitions of Machine Learning Testing

An ML bug refers to any imperfection in a

machine learning item that causes a discordance between the

existing and the required conditions.

Definition 1 (ML Bug).

Machine Learning Testing (ML testing) refers

to any activities designed to reveal machine learning bugs

Definition 2 (ML Testing).

Page 17: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

ML Testing Workflow

Page 18: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

ML Testing Workflow

Page 19: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Definitions of Machine Learning Testing

An ML bug refers to any imperfection in a

machine learning item that causes a discordance between the

existing and the required conditions.

Definition 1 (ML Bug).

Machine Learning Testing (ML testing) refers

to any activities designed to reveal machine learning bugs

Definition 2 (ML Testing).

Page 20: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Components Where the Bug May Exist

Page 21: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Definitions of Machine Learning Testing

An ML bug refers to any imperfection in a

machine learning item that causes a discordance between the

existing and the required conditions.

Definition 1 (ML Bug).

Machine Learning Testing (ML testing) refers

to any activities designed to reveal machine learning bugs

Definition 2 (ML Testing).

Page 22: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

ML Properties to TestCorrectness

Overfitting degree

Robustness

Security

Privacy

Fairness

Interpretability

Efficiency

Page 23: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

ML Properties to TestCorrectness

Overfitting degree

Robustness

Security

Privacy

Fairness

Interpretability

functional

Page 24: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

ML Properties to TestCorrectness

Overfitting degree

Robustness

Security

Privacy

Fairness

Interpretability

Efficiency

non-functional

Page 25: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 26: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Testing Workflow

Metamorphic relationsDifferential TestingN-version ProgrammingMetrics

Fuzzing symbolic executionDomain-specific synthesis: GAN

CoverageMutation testing

Input generation

oracle

adequacyevaluation

Page 27: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 28: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Supervised/Unsupervised/Reinforcement Learning

Page 29: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Machine Learning Properties

Page 30: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 31: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Challenges● Test Input Generation:

○ Safety-critical: Space coverage: enormous behaviour space of ML models

● The Oracle Problem: how to reduce false positives.

● Testing Cost Reduction.

Page 32: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Research Opportunities

● Test Input Generation:

○ Safety-critical: Space coverage

● The Oracle Problem: how to reduce false positives.

● Testing Cost Reduction.

SBST

Testability Transformation(Harman 2004)

Page 33: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Research Opportunities

● Test Input Generation:

○ Safety-critical: Space coverage

● The Oracle Problem: how to reduce false positives.

● Testing Cost Reduction.

Multiple oracles

Metamorphic relation: largely depend on inputs

Page 34: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Research Opportunities

● Test Input Generation:

○ Safety-critical: Space coverage

● The Oracle Problem: how to reduce false positives.

● Testing Cost Reduction.Test-cost reduction Transformation

Page 35: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Research Opportunities

● Unsupervised/reinforcement learning testing

● More machine learning properties: privacy, fairness

● More testing benchmarks

● More testing tools

● More testing activities

Page 36: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 37: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Model Selection and Overfitting Problem

Overfitting happens when a model :learns the detail and noise in the training data too well; the noise or random fluctuations in the training data is picked up and learned as concepts by the model.

Page 38: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Existing Research

cross-validation:

test error to approximate the generalisation error.

● test sample may not be be representative● different models may have very similar cross validation results

Applied Machine Learning

VC-dimension and Rademacher Complexity:

● only measure the complexity of the hypothesis space, not the fit

● both quantities are usually intractable in practice,

● Only provide bounds and the bound can be quite loose.

Statistical Machine Learning

Page 39: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

Our approach

Create different data versions by injecting noise

Retrain the model on each data version

Observe the decrease of training accuracy

Mutation Metamorphic Relations

Page 40: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 41: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that
Page 42: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

On real data sets

Page 43: Machine Learning Testing jie.zhang@ucl.ac.uk Jie M. Zhang ... - … · Definitions of Machine Learning Testing An ML bug refers to any imperfection in a machine learning item that

● Is now dealing with feedback from authors of the collected papers (have got around 70 responses so far).

● Will be on arXiv very soon.● Feel free to ask for a draft ([email protected])● Any feedback is very welcome!