Sys.setenv("RETICULATE_REMAP_OUTPUT_STREAMS" = 1)
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

ctgan

Codecov test coverage R build status

The ctgan package provides an R interface to CTGAN, a GAN-based data synthesizer. The package enables one to create synthetic samples of confidential or proprietary datasets for sharing. For more details and use cases, see the papers in the References section.

Installation

You can install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("kasaai/ctgan")

Example

A quick example:

library(ctgan)

# Install dependencies before first usage
# install_ctgan()

synthesizer <- ctgan()
synthesizer %>% 
  fit(iris, epochs = 20)
synthesizer %>% 
  ctgan_sample() %>% 
  # Dataset-specific post-processing
  dplyr::mutate_if(is.numeric, ~ pmax(.x, 0.1))

This generated dataset can then be shared, but one can also serialize and share the trained synthesizer:

model_dir <- tempdir()
synthesizer %>% 
  ctgan_save(model_dir)

ctgan_load(model_dir)

References

If you use ctgan, please consider citing the original work,

and the work implementing the R package,

@inproceedings{xu2019modeling,
  title={Modeling Tabular data using Conditional GAN},
  author={Xu, Lei and Skoularidou, Maria and Cuesta-Infante, Alfredo and Veeramachaneni, Kalyan},
  booktitle={Advances in Neural Information Processing Systems},
  year={2019}
}

@misc{kuo2019generative,
    title={Generative Synthesis of Insurance Datasets},
    author={Kevin Kuo},
    year={2019},
    eprint={1912.02423},
    archivePrefix={arXiv},
    primaryClass={stat.AP}
}


kasaai/ctgan documentation built on Feb. 19, 2020, 8:19 p.m.