Table of Contents

 

Preface

 

xiii

 

 

 

 

 

Chapter 1

Introduction

1

 

 

1.1 Machine learning vs. statistics

4

 

 

1.2 This book and the ancillary material

5

 

 

1.3 Types of machine learning models

6

 

 

1.4 Generative AI

8

 

 

1.5 Validation and testing

10

 

 

1.6 Data cleaning

18

 

 

1.7 Bayes theorem

20

 

 

Summary

22

 

 

Short concept questions

24

 

 

Exercises

24

 

 

 

 

 

Chapter 2

Unsupervised Learning

27

 

 

2.1 Feature scaling

28

 

 

2.2 The k-means algorithm

29

 

 

2.3 Choosing k

34

 

 

2.4 The curse of dimensionality

37

 

 

2.5 Country risk

38

 

 

2.6 Alternative clustering approaches

43

 

 

2.7 Principal components analysis

45

 

 

Summary

49

 

 

Short concept questions

50

 

 

Exercises

51

 

 

 

 

 

Chapter 3

Supervised Learning: Linear and Logistic Regression

 

53

 

 

3.1 Linear regression: one feature

54

 

 

3.2 Linear regression: multiple features

55

 

 

3.3 Categorical features

58

 

 

3.4 Regularization

60

 

 

3.5 Ridge regression

60

 

 

3.6 Lasso regression

64

 

 

3.7 Elastic Net regression

67

 

 

3.8 Application to Predicting House Prices

68

 

 

3.9 Logistic regression

73

 

 

3.10 Decision criteria

75

 

 

3.11 Application to credit decisions

76

 

 

3.12 The k-nearest neighbor algorithm

83

 

 

Summary

84

 

 

Short concept questions

85

 

 

Exercises

86

 

 

 

 

 

Chapter 4

Supervised Learning: Decision Trees

89

 

 

4.1 Nature of decision trees

90

 

 

4.2 Information gain measures

91

 

 

4.3 Application to LendingClub data

93

 

 

4.4 The nave Bayes classifier

98

 

 

4.5 Continuous target variables

102

 

 

4.6 Ensemble learning

106

 

 

Summary

107

 

 

Short concept questions

108

 

 

Exercises

109

 

 

 

 

 

Chapter 5

Supervised Learning: SVMs

111

 

 

5.1 Linear SVM classification

111

 

 

5.2 Modification for soft margin

118

 

 

5.3 Non-linear separation

121

 

 

5.4 Predicting a targets value

123

 

 

Summary

126

 

 

Short concept questions

127

 

 

Exercises

128

 

 

 

 

 

Chapter 6

Supervised Learning: Neural Networks

129

 

 

6.1 ANNs with a single hidden layer

129

 

 

6.2 Multi-layer ANNs

134

 

 

6.3 Other activation functions

136

 

 

6.4 Gradient descent algorithm

138

 

 

6.5 Variations on the basic method

144

 

 

6.6 The stopping rule

145

 

 

6.7 The Black−Scholes−Merton formula

147

 

 

6.8 Extensions

150

 

 

6.9 Understanding volatility movements

151

 

 

Summary

156

 

 

Short concept questions

156

 

 

Exercises

 

 

157

 

 

Chapter 7

Further Applications of Neural Networks

159

 

 

7.1 Autoencoders and PCA

159

 

 

7.2 General autoencoder design

162

 

 

7.3 Variational autoencoders

164

 

 

7.4 Generative adversarial networks

166

 

 

7.5 Recurrent neural networks

169

 

 

7.6 Convolutional neural networks

170

 

 

Summary

174

 

 

Short concept questions

175

 

 

Exercises

176

 

 

 

 

 

 

 

 

 

Chapter 8

Reinforcement Learning

177

 

 

8.1 The multi-armed bandit problem

178

 

 

8.2 Changing environment

183

 

 

8.3 The game of Nim

185

 

 

8.4 Temporal difference learning

188

 

 

8.5 When the opponent learns

191

 

 

8.6 Deep Q-learning

192

 

 

8.7 Distributional reinforcement learning

192

 

 

8.8 Playing chess

193

 

 

8.9 Applications

194

 

 

8.10 Optimal trade execution

196

 

 

8.11 Data issues

198

 

 

Summary

199

 

 

Short concept questions

200

 

 

Exercises

201

 

 

 

 

 

Chapter 9

Natural Language Processing

203

 

 

9.1 NLP Generations

204

 

 

9.2 Generation 1

206

 

 

9.3 Generation 2

208

 

 

9.4 Generation 3

210

 

 

9.5 Generation 4

212

 

 

Summary

212

 

 

Short concept questions

213

 

 

Exercises

214

 

 

Chapter 10

 

Sentiment Analysis

 

215

 

 

10.1 Pre-processing

217

 

 

10.2 Word Lists

218

 

 

10.3 Naive Bayes classifier

219

 

 

10.4 Application of other algorithms

223

 

 

10.5 Sentiment analysis for stock trading

224

 

 

Summary

227

 

 

Short concept questions

227

 

 

Exercises

227

 

 

Chapter 11

 

Large Language Models

 

229

 

 

11.1 General Concepts of LLMs

230

 

 

11.2 Foundation LLMs and limitations

232

 

 

11.3 Retrieval augmented generation

235

 

 

11.4 Prompt Engineering

237

 

 

11.5 Applications of LLMs

239

 

 

11.6 LLM agentic system

245

 

 

Summary

246

 

 

Short concept questions

246

 

 

Exercises

247

 

 

Chapter 12

 

Model Interpretability

 

249

 

 

12.1 Linear regression

252

 

 

12.2 Logistic regression

255

 

 

12.3 Black-box models

258

 

 

12.4 Local interpretability

260

 

 

12.5 Global Interpretability

264

 

 

Summary

265

 

 

Short concept questions

266

 

 

Exercises

267

 

 

 

 

 

Chapter 13

Issues for Society and AI Regulations

269

 

 

13.1 Data privacy

270

 

 

13.2 Biases

271

 

 

13.3 Ethics

273

 

 

13.4 Transparency

274

 

 

13.5 Adversarial machine learning

275

 

 

13.6 Legal issues

276

 

 

13.7 AI Regulations

277

 

 

13.8 Man vs. machine

279

 

 

 

 

 

Answers to Short Concept Questions

 

283

Glossary of Terms

 

305

Index

 

319