Skip to content

Instantly share code, notes, and snippets.

@petrosDemetrakopoulos
Last active April 19, 2023 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrosDemetrakopoulos/f3f7542a79c84895a889401568bc5651 to your computer and use it in GitHub Desktop.
Save petrosDemetrakopoulos/f3f7542a79c84895a889401568bc5651 to your computer and use it in GitHub Desktop.
discrete_columns = [
'hop 1 form',
'hop 2 form',
'hop 3 form',
'hop 4 form',
'hop 1 phase',
'hop 2 phase',
'hop 3 phase',
'hop 4 phase',
'hop 1 name',
'hop 2 name',
'hop 3 name',
'hop 4 name',
'fermentable 1 name',
'fermentable 2 name',
'fermentable 3 name',
'fermentable 4 name',
'fermentable 5 name',
'yeast'
]
df['batch'] = df['batch'].astype(float)
imp = SimpleImputer(strategy='most_frequent', missing_values='-', keep_empty_features=True)
cols = df.columns
imputed = imp.fit_transform(df)
df = pd.DataFrame(imputed, columns=cols)
df['batch'] = df['batch'].astype(float)
df['fermentable 1 weight'] = df['fermentable 1 weight'].astype(float)
df['fermentable 2 weight'] = df['fermentable 2 weight'].astype(float)
df['fermentable 3 weight'] = df['fermentable 3 weight'].astype(float)
df['fermentable 4 weight'] = df['fermentable 4 weight'].astype(float)
df['fermentable 5 weight'] = df['fermentable 5 weight'].astype(float)
df['hop 1 weight'] = df['hop 1 weight'].astype(float)
df['hop 2 weight'] = df['hop 2 weight'].astype(float)
df['hop 3 weight'] = df['hop 3 weight'].astype(float)
df['hop 4 weight'] = df['hop 4 weight'].astype(float)
df['hop 1 time'] = df['hop 1 time'].astype(float)
df['hop 2 time'] = df['hop 2 time'].astype(float)
df['hop 3 time'] = df['hop 3 time'].astype(float)
df['hop 4 time'] = df['hop 4 time'].astype(float)
df['yeast'] = df['yeast'].astype(str)
ctgan = CTGAN(epochs=45, cuda=True, verbose=True)
ctgan.fit(df, discrete_columns)
# Create synthetic data
synthetic_data = ctgan.sample(20)
synthetic_data.to_csv('./synthetic_recipes_45_epochs.csv')
print(synthetic_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment