Create main.py
Browse files
main.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import argparse
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
from generate_schema import generate_schema
|
5 |
+
from fetch_data import fetch_real_data
|
6 |
+
from synthetic_generator import train_and_generate_synthetic
|
7 |
+
|
8 |
+
def main():
|
9 |
+
parser = argparse.ArgumentParser()
|
10 |
+
parser.add_argument("--prompt", type=str, required=True, help="Describe the dataset you want")
|
11 |
+
parser.add_argument("--domain", type=str, default="healthcare", help="Domain to fetch real data from (optional)")
|
12 |
+
args = parser.parse_args()
|
13 |
+
|
14 |
+
# Retrieve API token from Streamlit secrets
|
15 |
+
hf_token = st.secrets["hf_token"]
|
16 |
+
|
17 |
+
# Step 1: Generate schema using LLM
|
18 |
+
schema = generate_schema(args.prompt, hf_token)
|
19 |
+
print(f"📊 Generated schema: {schema}")
|
20 |
+
|
21 |
+
# Step 2: Fetch real data (optional)
|
22 |
+
real_data = fetch_real_data(args.domain)
|
23 |
+
|
24 |
+
# Step 3: Preprocess (if necessary)
|
25 |
+
real_data = real_data[schema['columns']] # Match columns from schema
|
26 |
+
print(f"✅ Fetched real data with shape: {real_data.shape}")
|
27 |
+
|
28 |
+
# Step 4: Train GAN and generate synthetic data
|
29 |
+
output_path = f"outputs/synthetic_{args.domain}.csv"
|
30 |
+
train_and_generate_synthetic(real_data, schema, output_path)
|
31 |
+
|
32 |
+
if __name__ == "__main__":
|
33 |
+
main()
|