Skip to main content

Practice

  • Chapter
  • First Online:
Machine Learning Safety

Abstract

In this chapter, we will explain how to install an experimental environment based on Python, and present a few examples of basic Python operations and the code for the visualisation of a simple dataset (as in Example 1.4) and the confusion matrix (as introduced in Sect. 2.4).

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 79.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Exercises

Exercises

Question 1

Give an example for a supervised learning problem, an unsupervised learning problem, and a semi-supervised learning problem; â–¡

Question 2

Give an example of a supervised learning problem that is a classification task; â–¡

Question 3

Give an example of a supervised learning problem that is a regression task; â–¡

Question 4

Give an example of a clustering problem; â–¡

Question 5

For all the above problems, figure out the features and labels for them; â–¡

Question 6

Write a program to output the following information:

  1. 1.

    How many samples are in the iris dataset;

  2. 2.

    How many features are given for each sample in the iris dataset?

  3. 3.

    What is the value range for each feature?

â–¡

Question 7

According to Table 4.1 about two random variables Intelligence and Grade, please compute the values P(Grade = B | Intelligence = Low) and MAP(Grade).

Table 4.1 Joint probability for student grade and intelligence

Question 8

Consider a joint distribution table as in Table 4.2, can you compute the following expressions:

Table 4.2 Joint distribution table
  • P(A=1)=0.6

  • P(A=2)=0.3

  • P(B=3)=0.4

  • P(B=4)=0.1

  • P(A=1—B=2)=0.6

  • P(B=3—A=3)=0.4

  • MAP(A—B=2)=1

  • MAP(B—A=2)=3

  • MAP(A)=1

  • MAP(B)=3

â–¡

Question 9

Consider a joint distribution table as in Table 4.3, can you compute the following expressions:

Table 4.3 Joint distribution table
  • P(A=1)=0.56

  • P(A=2)=0.3

  • P(B=3)=0.4

  • P(B=4)=0.06

  • P(A=1—B=2)=0.6

  • P(B=3—A=3)=2/7

  • MAP(A—B=2)=1

  • MAP(B—A=2)=3

  • MAP(A)=1

  • MAP(B)=3

â–¡

Question 10

Write a program to implement

  • ROC curve

  • PR curve

â–¡

Question 11

Compare a few training/test splits (0.9/0.1, 0.8/0.2, 0.7/0.3) and check their differences on training and test accuracy. â–¡

Question 12

Compare a few training/test splits (0.9/0.1, 0.8/0.2, 0.7/0.3) and check their differences on confusion matrix. â–¡

Question 13

Find a data poisoning strategy to make the trained model mis-classify on a given training input. â–¡

Question 14

Read the literature to understand the state-of-the-art for backdoor attacks. â–¡

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this chapter

Cite this chapter

Huang, X., Jin, G., Ruan, W. (2023). Practice. In: Machine Learning Safety. Artificial Intelligence: Foundations, Theory, and Algorithms. Springer, Singapore. https://doi.org/10.1007/978-981-19-6814-3_4

Download citation

  • DOI: https://doi.org/10.1007/978-981-19-6814-3_4

  • Published:

  • Publisher Name: Springer, Singapore

  • Print ISBN: 978-981-19-6813-6

  • Online ISBN: 978-981-19-6814-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics