Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- requirements.txt +13 -0
- s_cg.py +49 -0
requirements.txt
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Automatically generated by https://github.com/damnever/pigar.
|
2 |
+
|
3 |
+
# C:\Users\DINGOO KARTHICK\Desktop\Learning\Coding\RFM\Syn Data\s_cg.py: 2
|
4 |
+
numpy == 1.23.5
|
5 |
+
|
6 |
+
# C:\Users\DINGOO KARTHICK\Desktop\Learning\Coding\RFM\Syn Data\s_cg.py: 1
|
7 |
+
pandas == 1.5.3
|
8 |
+
|
9 |
+
# C:\Users\DINGOO KARTHICK\Desktop\Learning\Coding\RFM\Syn Data\s_cg.py: 5
|
10 |
+
streamlit == 1.29.0
|
11 |
+
|
12 |
+
# C:\Users\DINGOO KARTHICK\Desktop\Learning\Coding\RFM\Syn Data\s_cg.py: 4
|
13 |
+
ydata_synthetic == 1.0.1
|
s_cg.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
+
from ydata_synthetic.synthesizers.regular import RegularSynthesizer
|
4 |
+
from ydata_synthetic.synthesizers import ModelParameters, TrainParameters
|
5 |
+
import streamlit as st
|
6 |
+
from os import getcwd
|
7 |
+
text_file=st.file_uploader("Upload the Data File")
|
8 |
+
st.write("-------------------------")
|
9 |
+
|
10 |
+
if text_file is not None:
|
11 |
+
df=pd.read_csv(text_file)
|
12 |
+
dd_list=df.columns
|
13 |
+
cat_cols=st.multiselect("Select the Categorical Columns",dd_list)
|
14 |
+
num_cols=st.multiselect("Select the Numerical Columns",dd_list)
|
15 |
+
Output_file=st.text_input('Enter Output File Name')
|
16 |
+
s=st.number_input('Enter the Sample Size',1000)
|
17 |
+
OP=Output_file + '.csv'
|
18 |
+
sub=st.button('Submit')
|
19 |
+
if sub:
|
20 |
+
batch_size = 50
|
21 |
+
epochs = 3
|
22 |
+
learning_rate = 2e-4
|
23 |
+
beta_1 = 0.5
|
24 |
+
beta_2 = 0.9
|
25 |
+
|
26 |
+
ctgan_args = ModelParameters(batch_size=batch_size,
|
27 |
+
lr=learning_rate,
|
28 |
+
betas=(beta_1, beta_2))
|
29 |
+
|
30 |
+
train_args = TrainParameters(epochs=epochs)
|
31 |
+
synth = RegularSynthesizer(modelname='ctgan', model_parameters=ctgan_args)
|
32 |
+
synth.fit(data=df, train_arguments=train_args, num_cols=num_cols, cat_cols=cat_cols)
|
33 |
+
df_syn = synth.sample(s)
|
34 |
+
df_syn.to_csv(OP)
|
35 |
+
c=getcwd()
|
36 |
+
c=c + '/' + OP
|
37 |
+
with open(c,"rb") as file:
|
38 |
+
st.download_button(label=':blue[Download]',data=file,file_name=OP,mime="image/png")
|
39 |
+
st.success("Thanks for using the app !!!")
|
40 |
+
# st.markdown("""
|
41 |
+
# <style>
|
42 |
+
|
43 |
+
|
44 |
+
# /* Hide Streamlit Branding */
|
45 |
+
# #MainMenu {visibility: hidden;}
|
46 |
+
# footer {visibility: hidden;}
|
47 |
+
# header {visibility: hidden;}
|
48 |
+
# </style>
|
49 |
+
# """, unsafe_allow_html=True)
|