#### Overview of this book

Machine Learning for Finance explores new advances in machine learning and shows how they can be applied across the financial sector, including insurance, transactions, and lending. This book explains the concepts and algorithms behind the main machine learning techniques and provides example Python code for implementing the models yourself. The book is based on Jannes Klaas’ experience of running machine learning training courses for financial professionals. Rather than providing ready-made financial algorithms, the book focuses on advanced machine learning concepts and ideas that can be applied in a wide variety of ways. The book systematically explains how machine learning works on structured data, text, images, and time series. You'll cover generative adversarial learning, reinforcement learning, debugging, and launching machine learning products. Later chapters will discuss how to fight bias in machine learning. The book ends with an exploration of Bayesian inference and probabilistic programming.
Machine Learning for Finance
Contributors
Preface
Other Books You May Enjoy
Free Chapter
Applying Machine Learning to Structured Data
Utilizing Computer Vision
Understanding Time Series
Parsing Textual Data with Natural Language Processing
Using Generative Models
Reinforcement Learning for Financial Markets
Privacy, Debugging, and Launching Your Products
Fighting Bias
Bayesian Inference and Probabilistic Programming
Index

## Dilated and causal convolution

As discussed in the section on backtesting, we have to make sure that our model does not suffer from look-ahead bias:

Standard convolution does not take the direction of convolution into account

As the convolutional filter slides over the data, it looks into the future as well as the past. Causal convolution ensures that the output at time t derives only from inputs from time t - 1:

Causal convolution shifts the filter in the right direction

In Keras, all we have to do is set the `padding` parameter to `causal`. We can do this by executing the following code:

`model.add(Conv1D(16,5, padding='causal'))`

Another useful trick is dilated convolutional networks. Dilation means that the filter only accesses every nth element, as we can see in the image below.

Dilated convolution skips over inputs while convolving

In the preceding diagram, the upper convolutional layer has a dilation rate of 4 and the lower layer a dilation rate of 1. We can set the dilation rate in Keras by running...