Spaces:
Runtime error
Runtime error
Commit
·
24dcd2b
1
Parent(s):
e5db09b
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,17 +5,20 @@ from scipy.io import arff
|
|
| 5 |
|
| 6 |
rtf_model = REaLTabFormer(
|
| 7 |
model_type="tabular",
|
| 8 |
-
gradient_accumulation_steps=
|
| 9 |
|
| 10 |
|
| 11 |
def generate_data(file):
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
rtf_model.fit(df)
|
| 15 |
# Generate synthetic data
|
| 16 |
samples = rtf_model.sample(n_samples=5)
|
| 17 |
|
| 18 |
-
return samples
|
| 19 |
|
| 20 |
css = """
|
| 21 |
.gradio-container {
|
|
@@ -114,13 +117,17 @@ with gr.Blocks(css = css) as demo:
|
|
| 114 |
|
| 115 |
with gr.Tab("Upload Data as File"):
|
| 116 |
data_input_u = gr.File(label = 'Upload Data File', file_types=["text", ".json", ".csv", ".arff"])
|
|
|
|
| 117 |
generate_data_btn = gr.Button('Generate Synthetic Data')
|
| 118 |
|
| 119 |
with gr.Row():
|
|
|
|
| 120 |
data_output = gr.Dataframe(label = "Synthetic Data")
|
|
|
|
| 121 |
|
| 122 |
|
| 123 |
-
generate_data_btn.click(generate_data, inputs = data_input_u, outputs = [data_output])
|
|
|
|
| 124 |
|
| 125 |
|
| 126 |
demo.launch()
|
|
|
|
| 5 |
|
| 6 |
rtf_model = REaLTabFormer(
|
| 7 |
model_type="tabular",
|
| 8 |
+
gradient_accumulation_steps=1)
|
| 9 |
|
| 10 |
|
| 11 |
def generate_data(file):
|
| 12 |
+
if '.arff' in file.name:
|
| 13 |
+
data = arff.loadarff(open(file.name,'rt'))
|
| 14 |
+
df = pd.DataFrame(data[0])
|
| 15 |
+
elif '.csv' in file.name:
|
| 16 |
+
df = pd.read_csv(file.name)
|
| 17 |
rtf_model.fit(df)
|
| 18 |
# Generate synthetic data
|
| 19 |
samples = rtf_model.sample(n_samples=5)
|
| 20 |
|
| 21 |
+
return df.head(),samples
|
| 22 |
|
| 23 |
css = """
|
| 24 |
.gradio-container {
|
|
|
|
| 117 |
|
| 118 |
with gr.Tab("Upload Data as File"):
|
| 119 |
data_input_u = gr.File(label = 'Upload Data File', file_types=["text", ".json", ".csv", ".arff"])
|
| 120 |
+
num_samples = gr.Slider(label="Number of Samples", minimum=5, maximum=100, value=5, step=10)
|
| 121 |
generate_data_btn = gr.Button('Generate Synthetic Data')
|
| 122 |
|
| 123 |
with gr.Row():
|
| 124 |
+
data_sample = gr.Dataframe(label = "Original Data")
|
| 125 |
data_output = gr.Dataframe(label = "Synthetic Data")
|
| 126 |
+
|
| 127 |
|
| 128 |
|
| 129 |
+
generate_data_btn.click(generate_data, inputs = [data_input_u,num_samples], outputs = [data_sample, data_output])
|
| 130 |
+
examples = gr.Examples(examples=[['diabetes.arff',5]],inputs = [data_input_u,num_samples], outputs = [data_sample, data_output], cache_examples = True, fn = process)
|
| 131 |
|
| 132 |
|
| 133 |
demo.launch()
|