Skip to content

Instantly share code, notes, and snippets.

@johntmyers
johntmyers / create_report.py
Created Oct 7, 2020
Gretel Synthetics Report Generation
View create_report.py
# With the latest Premium SDK, you can write your report to a HTML file for archiving and distribution
# ... assuming you have a ``bundle`` object from previous synthetic workloads
bundle.generate_report(report_path="./my_report.html")
@johntmyers
johntmyers / sample.py
Last active Aug 11, 2020
shhgit-test.py
View sample.py
# le super secret
GRETEL_API_KEY=MYLOYALROYALSUBJECT
@johntmyers
johntmyers / response.json
Created Jul 1, 2020
Gretel Sync API Response Example
View response.json
{
"data": {
"records": [
{
"data": {
"Unnamed: 0": 2135731,
"Unnamed: 0.1": 2135731,
"id": null,
"member_id": null,
"loan_amnt": 12000,
@johntmyers
johntmyers / train_and_gen.py
Created Jun 15, 2020
gretel-synthetics-0.10.0-part3
View train_and_gen.py
# ``batcher`` is our ``DataFrameBatch`` instance
# this creates a DataFrame and a "train.csv" file for each of our batches
batcher.create_training_data()
# loops over all batches, and generates the models
batcher.train_all_batches()
# loops over all models, and generates synthetic lines for each one
#
@johntmyers
johntmyers / validator.py
Created Jun 15, 2020
gretel-synthetics-0.10.0-part2
View validator.py
# ``batcher`` is our ``DataFrameBatch`` instance
def my_validator(line: str) -> bool:
# ``str`` is a single line of generated text
# return a bool, True for valid, False for invalid
# throwing an Exception also invalidates the line
...
# set a validator function for our first batch
batcher.set_batch_validator(0, my_validator)
@johntmyers
johntmyers / init.py
Last active Jun 15, 2020
gretel-synthetics-0.10.0-example-1
View init.py
# pip install gretel-synthetics
from gretel_synthetics.batch import DataFrameBatch
# my_source_df = ...
# Same configurations parameters as using LocalConfig
# https://gretel-synthetics.readthedocs.io/en/stable/api/config.html
config_template = {
"max_lines": 0,
@johntmyers
johntmyers / converter.py
Last active May 22, 2020
String to regex converter
View converter.py
import re
def _sub_special_chars_any(in_string: str):
return re.sub("[^a-z\d\s]", ".?", in_string)
def _mark_substrings_optional(in_string: str, n=3):
parts = in_string.split()
if len(parts) == 1:
View keybase.md

Keybase proof

I hereby claim:

  • I am johntmyers on github.
  • I am johntmyers (https://keybase.io/johntmyers) on keybase.
  • I have a public key ASCqahqpY4OgOzF1bwaJlaMIsZRl9NTqNWVvmiPiHArQXwo

To claim this, I am signing this object: