Một mục tích hợp AI trong kho dữ liệu GitHub của TopGit: stefan-jansen/synthetic-data-for-finance, 131 sao, nhóm AI Tools, Jupyter Notebook. Material for QuantUniversity talk on Sythetic Data Generation for Finance.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Generative Adversarial Nets for Synthetic Time Series Data
This repo shows how to create synthetic time-series data using generative adversarial networks (GAN). GANs train a generator and a discriminator network in a competitive setting so that the generator learns to produce samples that the discriminator cannot distinguish from a given class of training data. The goal is to yield a generative model capable of producing synthetic samples representative of this class.
While most popular with image data, GANs have also been used to generate synthetic time-series data in the medical domain. Subsequent experiments with financial data explored whether GANs can produce alternative price trajectories useful for ML training or strategy backtests.
We replicate the 2019 NeurIPS Time-Series GAN paper by Jinsung Yoon, et al., to illustrate the approach and demonstrate the results. The material is based on the 2nd edition of my book on Machine Learning for Trading (see GitHub repo).
Content
Generative adversarial networks for synthetic data
Comparing generative and discriminative models
Adversarial training: a zero-sum game of trickery
Code example: TimeGAN: Adversarial Training for Synthetic Financial Data
Learning the data generation process across features and time
Combining adversarial and supervised training with time-series embedding
The four components of the TimeGAN architecture
Implementing TimeGAN using TensorFlow 2
Evaluating the quality of synthetic time-series data
Resources
How GAN's work
Implementation
The rapid evolution of the GAN architecture zoo
Applications
Generative adversarial networks for synthetic data
The book mostly focuses on supervised learning algorithms that receive input data and predict an outcome, which we can compare to the ground truth to evaluate their performance. Such algorithms are also called discriminative models because they learn to differentiate between different output values.
Generative adversarial networks (GANs) are an instance of generative models like the variational autoencoder covered in Chapter 20.
Comparing generative and discriminative models
Discriminative models learn how to differentiate among outcomes y, given input data X. In other words, they learn the probability of the outcome given the data: p(y | X). Generative models, on the other hand, learn the joint distribution of inputs and outcome p(y, X).
While generative models can be used as discriminative models using Bayes Rule to compute which class is most likely (see Chapter 10), it appears often preferable to solve the prediction problem directly rather than by solving the more general generative challenge first.
Adversarial training: a zero-sum game of trickery
The key innovation of GANs is a new way of learning the data-generating probability distribution. The algorithm sets up a competitive, or adversarial game between two neural networks called the generator and the discriminator.
Code example: How to build a GAN using TensorFlow 2
To illustrate the implementation of a generative adversarial network using Python, we use the deep convolutional GAN (DCGAN) example discussed earlier in this section to synthesize images from the fashion MNIST dataset that we first encountered in Chapter 13.
The notebook deep_convolutional_generative_adversarial_network illustrates the implementation of a GAN using Python. It uses the Deep Convolutional GAN (DCGAN) example to synthesize images from the fashion MNIST dataset
Code example: TimeGAN: Adversarial Training for Synthetic Financial Data
Generating synthetic time-series data poses specific challenges above and beyond those encountered when designing GANs for images.
In addition to the distribution over variables at any given point, such as pixel values or the prices of numerous stocks, a generative model for time-series data should also learn the temporal dynamics that shapes how one sequence of observations follows another (see also discussion in Chapter 9: Time Series Models for Volatility Forecasts and Statistical Arbitrage).
Very recent and promising research by Yoon, Jarrett, and van der Schaar, presented at NeurIPS in December 2019, introduces a novel Time-Series Generative Adversarial Network (TimeGAN) framework that aims to account for temporal correlations by combining supervised and unsupervised training.
The model learns a time-series embedding space while optimizing both supervised and adversarial objectives that encourage it to adhere to the dynamics observed while sampling from historical data during training.
The authors test the model on various time series, including historical stock prices, and find that the quality of the synthetic data significantly outperforms that of available alternatives.
Learning the data generation process across features and time
A successful generative model for time-series data needs to capture both the cross-sectional distribution of features at each point in time and the longitudinal relationships among these features over time.
Expressed in the image context we just discussed, the model needs to learn not only what a realistic image looks like, but also how one image evolves from the next as in a video.
Combining adversarial and supervised training with time-series embedding
Prior attempts at generating time-series data like the recurrent (conditional) GAN relied on recurrent neural networks (RNN, see Chapter 19, RNN for Multivariate Time Series and Sentiment Analysis) in the roles of generator and discriminator.
TimeGAN explicitly incorporates the autoregressive nature of time series by combining the unsupervised adversarial loss on both real and synthetic sequences familiar from the DCGAN example with a stepwise supervised loss with respect to the original data.
The goal is to reward the model for learning the distribution over transitions from one point in time to the next present in the historical data.
The four components of the TimeGAN architecture
The TimeGAN architecture combines an adversarial network with an autoencoder and has thus four network components as depicted in Figure 21.4:
Autoencoder: embedding and recovery networks
Adversarial Network: sequence generator and sequence discriminator components
Implementing TimeGAN using TensorFlow 2
In this section, we implement the TimeGAN architecture just described. The authors provide sample code using TensorFlow 1 that we port to TensorFlow 2. Building and training TimeGAN requires several steps:
Selecting and preparing real and random time series inputs
Creating the key TimeGAN model components
Defining the various loss functions and train steps used during the three training phases
Running the training loops and logging the results
Generating synthetic time series and evaluating the results
The notebook TimeGAN_TF2 shows how to implement these steps.
Installation
Using a GPU is recommended to speed up training. There are several options to run the notebook:
Use a Docker image provided by TensorFlow with either CPU or GPU support. See instructions.
To start the container configured with TensorFlow and mount the project directory in the /home directory, run the following command in this repo's root folder on your machine:
With GPU support (using nvidia-docker as describe in the linked instructions):
docker run --gpus all -it -v $(pwd):/home -p 8888:8888 --name ml4t tensorflow/tensorflow:latest-gpu-jupyter bash
Create a virtual environment using the requirements.txt file (Ubuntu only; other OS requires modifying the content).
Evaluating the quality of synthetic time-series data
The TimeGAN authors assess the quality of the generated data with respect to three practical criteria:
Diversity: the distribution of the synthetic samples should roughly match that of the real data
Fidelity: the sample series should be indistinguishable from the real data, and
Usefulness: the synthetic data should be as useful as their real counterparts for solving a predictive task
The authors apply three methods to evaluate whether the synthetic data actually exhibits these characteristics:
Visualization: for a qualitative diversity assessment of diversity, we use dimensionality reduction (principal components analysis (PCA) and t-SNE, see Chapter 13) to visually inspect how closely the distribution of the synthetic samples resembles that of the original data
Discriminative Score: for a quantitative assessment of fidelity, the test error of a time-series classifier such as a 2-layer LSTM (see Chapter 18) let’s us evaluate whether real and synthetic time series can be differentiated or are, in fact, indistinguishable.
Predictive Score: for a quantitative measure of usefulness, we can compare the test errors of a sequence prediction model trained on, alternatively, real or synthetic data to predict the next time step for the real data.
The notebook evaluating_synthetic_data contains the relevant code samples.
Resources
How GAN's work
NIPS 2016 Tutorial: Generative Adversarial Networks, Ian Goodfellow, 2017
Why is unsupervised learning important?, Yoshua Bengio on Quora, 2018
GAN Lab: Understanding Complex Deep Generative Models using Interactive Visual Experimentation, Minsuk Kahng, Nikhil Thorat, Duen Horng (Polo) Chau, Fernanda B. Viégas, and Martin Wattenberg, IEEE Transactions on Visualization and Computer Graphics, 25(1) (VAST 2018), Jan. 2019
GitHub
Generative Adversarial Networks, Ian Goodfellow, et al, 2014
Generative Adversarial Networks: an Overview, Antonia Creswell, et al, 2017
Generative Models, OpenAI Blog
Implementation
Deep Convolutional Generative Adversarial Network
CycleGAN
Keras-GAN, numerous Keras GAN implementations
PyTorch-GAN, numerous PyTorch GAN implementations
The rapid evolution of the GAN architecture zoo
Unsupervised Representation Learning with Deep Convolutional Generative Adversarial Networks (DCGAN), Luke Metz et al, 2016
Conditional Generative Adversarial Net, Medhi Mirza and Simon Osindero, 2014
Infogan: Interpretable Representation Learning by Information Maximizing Generative Adversarial Nets, Xi Chen et al, 2016
Stackgan: Text to Photo-realistic Image Synthesis with Stacked Generative Adversarial Networks, Shaoting Zhang et al, 2016
Photo-realistic Single Image Super-resolution Using a Generative Adversarial Network, Alejando Acosta et al, 2016
Unpaired Image-to-image Translation Using Cycle-consistent Adversarial Networks, Juan-Yan Zhu et al, 2018
Learning What and Where to Draw, Scott Reed, et al 2016
Fantastic GANs and where to find them
Applications
Real-valued (Medical) Time Series Generation with Recurrent Conditional GANs, Cristóbal Esteban, Stephanie L. Hyland, Gunnar Rätsch, 2016
GitHub Repo
MAD-GAN: Multivariate Anomaly Detection for Time Series Data with Generative Adversarial Networks, Dan Li, Dacheng Chen, Jonathan Goh, and See-Kiong Ng, 2019
GitHub Repo
GAN — Some cool applications, Jonathan Hui, 2018
gans-awesome-applications, curated list of awesome GAN applications
Đọc thêm về stefan-jansen/synthetic-data-for-finance ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/stefan-jansen/synthetic-data-for-finance là nguồn chính thức.
stefan-jansen/synthetic-data-for-finance có bao nhiêu sao?
stefan-jansen/synthetic-data-for-finance có 131 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/stefan-jansen/synthetic-data-for-finance. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
stefan-jansen/synthetic-data-for-finance có những chủ đề gì?
GitHub topics của stefan-jansen/synthetic-data-for-finance: "algorithmic-trading", "finance", "generative-adversarial-network", "machine-learning", "synthetic-data". TopGit xếp repo vào nhóm AI Tools.
stefan-jansen/synthetic-data-for-finance có trang demo không?
Dự án có trang chủ ở https://quspeakerseries14.splashthat.com/. Tab "Readme" ở trang này thường có ảnh chụp và hướng dẫn bắt đầu nhanh.
stefan-jansen/synthetic-data-for-finance còn đang phát triển không?
Commit gần nhất trên stefan-jansen/synthetic-data-for-finance là 6.0 năm trước (theo timestamp GitHub). Repo có 47 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
stefan-jansen/synthetic-data-for-finance viết bằng ngôn ngữ gì?
stefan-jansen/synthetic-data-for-finance chủ yếu viết bằng Jupyter Notebook. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về synthetic-data-for-finance?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về synthetic-data-for-finance.