https://gretel.ai/blog/generate-synthetic-data-in-3-lines-of-code Skip to main Upcoming Workshop: Generate Synthetic Data from a Relational Database Workshop: Generate Synthetic Data from a Relational Database Sign up # Home Gretel.ai Logo # gretel logo Home Gretel Toolkit * [6181c] Synthetics Generate unlimited synthesized datasets. * [6181c] Transform Perform privacy-preserving transformations on sensitive data. * [6181c] Classify Identify PII with advanced NLP detection. * Explore our Toolkit # Developers * Docs * Gretel CLI * Rest API Reference * Slack Community * GitHub Company * Pricing * About * Team * Careers * Contact * Blog * Learn * News * Videos * Podcasts * All resources # Request a Demo Sign up or Sign in * Product + [61f47][61f47][61f47] [61f87dabb6f2a6809b] Gretel's Toolkit Gretel's toolkit includes Synthetics, Transform and Classify APIs to provide you with a complete set of tools to create safe data. + [6181c] Synthetics Generate unlimited synthesized datasets. + [6181c] Transform Perform privacy-preserving transformations on sensitive data. + [6181c] Classify Identify PII with advanced NLP detection. * Developers + # Documentation Get started creating safe data by reading our docs. + # Gretel CLI Install the gretel-client CLI tool. + # REST API reference An open source data transformation library and bindings to Gretel APIs. + # Get help on Slack Join our Slack community and ask questions to Gretel team members. + # GitHub View our open source projects and SDKs on GitHub. Getting started + # Environment Setup + # Architecture and Components + # Configure your model Tutorials + # Create Synthetic Data + # Balance a Dataset + # Redact Sensitive Data * Resources Company + Icon About + Icon News + # Team + # Careers + # Contact Resources + # Blog + # Learn NEW + # Videos + # Podcasts + # All resources From the blog Introducing Gretel Amplify Introducing Gretel Amplify Read the post # An update to Gretel's license to support continuous community growth and innovation An update to Gretel's license to support continuous community growth and innovation Read the post # * Blog * Pricing * Book a Demo * Sign in * Sign up Blog / Synthetics Generate synthetic data in 3 lines of code by Alex Watson August 24, 2022 [630670b82bc08b8153ff8814_Generate] Follow * GitHub GitHub * LinkedIn LinkedIn * Slack Slack * Twitter Twitter * YouTube YouTube Learn the simplest way to generate synthetic data without setting up your own infrastructure and GPUs. We are super excited to introduce the gretel-trainer, an interface designed to be the simplest way to generate synthetic data, and a preview of new features coming to Gretel's production SDK & API. Jason Warner, formerly CTO at GitHub and VP of Engineering at Heroku, has always had some advice that stuck with me -- "If it's 10 lines of code, make it 5. If it's 5 lines of code, make it 1". In today's post, we'll walk through a code example for generating synthetic data using gretel-trainer and how you can use it to create synthetic data for anything from the CSV you have on your computer to datasets with millions of rows of data and thousands of columns. Try out the code below, or follow along step-by-step with our notebook in Colab. First, start with installing the gretel-trainer library. pip install -Uqq gretel-trainer Below is the simplest path to creating synthetic data. This code uses Gretel's APIs to train a deep learning generative model on the popular US adult income dataset and to create an artificial, synthetic equivalent version. from gretel_trainer import trainer dataset = "https://gretel-public-website.s3-us-west-2.amazonaws.com/datasets/USAdultIncome5k.csv" # Simplest example model = trainer.Trainer() model.train(dataset) print(model.generate()) Want to load an existing trained model, and use it to generate more data? That's easy too! # Or, load and generate data from an existing model model = trainer.Trainer.load() model.generate(num_records=70) Need to customize your synthetic model? Selecting an underlying model and tuning model parameters is easier than ever. # Specify underlying model and config options. # configs can be either a string, dict, or path from gretel_trainer.models import GretelLSTM model_type = GretelLSTM(config="synthetics/default") # Optionally update model params from a base config model_type.update_params({'epochs': 50}) model = trainer.Trainer(model_type=model_type) model.train(dataset) model.generate() Since the gretel-trainer uses Gretel's fully managed cloud service for model training and generation, you can create state-of-the-art synthetic data without needing to set up or manage infrastructure and GPUs. Try running our Colab notebook, and for the next steps, try running on one of your own datasets or CSVs. Have questions? Ask for help on Gretel.ai's community Slack. What's next: In part 2 of this post, we will dive into more advanced use cases using gretel-trainer to modify distributions in underlying data -- a valuable technique for improving ML detection for fraud in cyber and financial datasets using conditional data generation. Connect with the Gretel Community. Join our Slack community to connect with the Gretel team and engage with our community. Slack logo Join gretelgroup.slack.com Stay connected Subscribe to our newsletter to receive Gretel news and blog posts directly to your inbox. Email address [ ][Subscribe] Thank you for subscribing! Oops! Something went wrong while submitting the form. Similar posts [5f4ebdec8b] Gretel Synthetics Frequently Asked Questions (FAQs) Alex Watson August 24, 2022 Copyright (c) 2021 Gretel.ai Why Nonprofits Should Care About Synthetic Data Daniel Nissani August 24, 2022 [5f9860f682] Introducing Gretel Blueprints John Myers August 24, 2022 Product * Synthetics * Classify * Transformation * Documentation FAQs * Gretel Cloud * Gretel Synthetics Company * About us * Team * Careers (We're hiring!) * Blog * Contact Media * All Media * News * Videos * Podcasts Social * GitHub * Twitter * LinkedIn * YouTube Community * Slack Community * Code of Coduct Legal * Privacy Policy * Terms of Service * Acceptable Use Policy * Responsible Disclosure * License Gretel logo Copyright (c) 2022 Gretel Labs. All rights reserved. API Status: Checking...