CoolFace
Apppublic

SherinJosephRoy/synthetic-data-generator

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
1likes
App README

๐ŸŽฒ Synthetic Data Generator

A comprehensive, privacy-preserving synthetic data generation platform built with Gradio. Create realistic datasets for testing, development, and analysis while maintaining data privacy and quality.

Synthetic Data Generator Python Gradio License

โœจ Features

๐Ÿ—๏ธ Visual Schema Builder

  • โ€”Drag-and-drop field management
  • โ€”25+ data types with realistic generators
  • โ€”Advanced constraints and validation
  • โ€”Real-time schema preview

๐Ÿ“‹ Pre-built Templates

  • โ€”Customer Database
  • โ€”E-commerce Transactions
  • โ€”Employee Records
  • โ€”Healthcare Records
  • โ€”Social Media Posts
  • โ€”IoT Sensor Data
  • โ€”Financial Transactions
  • โ€”User Clickstream Data
  • โ€”Product Catalog
  • โ€”Marketing Campaigns

๐Ÿ”’ Privacy Protection

  • โ€”Low: Realistic but identifiable data
  • โ€”Medium: Anonymized with masking/fuzzing
  • โ€”High: Fully anonymous with differential privacy
  • โ€”PII detection and risk assessment
  • โ€”K-anonymity validation

๐Ÿ“Š Data Quality Controls

  • โ€”Configurable missing values (0-20%)
  • โ€”Outlier injection (0-10%)
  • โ€”Duplicate creation (0-5%)
  • โ€”Statistical noise addition
  • โ€”Data validation and quality reports

๐Ÿ“ค Multiple Export Formats

  • โ€”CSV, JSON (array/lines), Excel, Parquet
  • โ€”SQL INSERT statements
  • โ€”Python Pandas DataFrame code
  • โ€”Compression support (ZIP)

๐Ÿค– AI-Powered Generation

  • โ€”GPT-2 integration for realistic text
  • โ€”Context-aware content generation
  • โ€”Fallback to Faker for performance
  • โ€”Custom pattern learning

๐Ÿš€ Quick Start

1. Choose a Template

Navigate to the Templates tab and select from 10 pre-built schemas:

  • โ€”Customer Database
  • โ€”E-commerce Transactions
  • โ€”Employee Records
  • โ€”Healthcare Records
  • โ€”And more...

2. Customize Your Schema

Use the Schema Builder to:

  • โ€”Add/remove fields
  • โ€”Set constraints and validation rules
  • โ€”Configure data types and subtypes
  • โ€”Define relationships between fields

3. Generate Data

In the Generate tab:

  • โ€”Set number of rows (10 - 100,000)
  • โ€”Choose privacy level
  • โ€”Configure data quality parameters
  • โ€”Set random seed for reproducibility

4. Export Your Data

Download in your preferred format:

  • โ€”CSV for spreadsheets
  • โ€”JSON for APIs
  • โ€”Excel for business users
  • โ€”Parquet for big data
  • โ€”SQL for databases
  • โ€”Python code for development

๐Ÿ“‹ Supported Data Types

Text Fields

TypeDescriptionExample
namePerson names"John Smith"
emailEmail addresses"john@example.com"
addressStreet addresses"123 Main St"
phonePhone numbers"(555) 123-4567"
companyCompany names"Acme Corp"
job_titleJob titles"Software Engineer"
descriptionProduct descriptions"High-quality product..."
urlWeb URLs"https://example.com"
credit_cardCredit card numbers"4532-1234-5678-9012"
ipv4IPv4 addresses"192.168.1.1"

Numeric Fields

TypeDescriptionExample
integerRandom integers42
floatRandom floats3.14159
percentagePercentage values85.5
currencyCurrency amounts$1,234.56
ageAge values28
salarySalary amounts$75,000
ratingRating values4.5
latitudeLatitude coordinates40.7128
longitudeLongitude coordinates-74.0060

Date Fields

TypeDescriptionExample
dateRandom dates2024-01-15
datetimeDate and time2024-01-15 14:30:00
signup_dateSignup dates (weekday bias)2024-01-15
transaction_dateTransaction dates (business hours)2024-01-15 10:30:00
hire_dateHire dates2024-01-15

Special Fields

TypeDescriptionExample
booleanTrue/False valuestrue
categoricalCustom categories"Premium", "Basic"

๐Ÿ”’ Privacy Features

Privacy Levels

Low Privacy
  • โ€”Realistic, identifiable data
  • โ€”Suitable for internal testing
  • โ€”No anonymization applied
Medium Privacy
  • โ€”Email Masking: j***@example.com
  • โ€”Name Masking: J*** S***
  • โ€”Phone Masking: ***-***-1234
  • โ€”Address Masking: 123 *** St
  • โ€”Date Fuzzing: ยฑ30 days random shift
High Privacy
  • โ€”Pseudonymization: Replace with generic values
  • โ€”Differential Privacy: Statistical noise addition
  • โ€”K-anonymity: Group-based anonymization
  • โ€”Generalization: Reduce data specificity

PII Detection

  • โ€”Automatic detection of sensitive data
  • โ€”Risk level assessment (Low/Medium/High)
  • โ€”Privacy report generation
  • โ€”Compliance recommendations

๐Ÿ“Š Data Quality Features

Missing Values

  • โ€”Configurable percentage (0-20%)
  • โ€”Realistic missing patterns
  • โ€”Field-specific null rates

Outliers

  • โ€”Statistical outlier injection (0-10%)
  • โ€”Realistic outlier patterns
  • โ€”Numeric field support

Duplicates

  • โ€”Duplicate record creation (0-5%)
  • โ€”Configurable duplicate patterns
  • โ€”Relationship preservation

Validation

  • โ€”Schema validation
  • โ€”Data type checking
  • โ€”Constraint enforcement
  • โ€”Quality score calculation

๐Ÿ› ๏ธ Technical Details

Architecture

synthetic-data-generator/
โ”œโ”€โ”€ app.py                 # Main Gradio application
โ”œโ”€โ”€ requirements.txt       # Python dependencies
โ”œโ”€โ”€ generators/           # Data generation modules
โ”‚   โ”œโ”€โ”€ base_generator.py
โ”‚   โ”œโ”€โ”€ text_generator.py
โ”‚   โ”œโ”€โ”€ numeric_generator.py
โ”‚   โ”œโ”€โ”€ date_generator.py
โ”‚   โ””โ”€โ”€ ai_generator.py
โ”œโ”€โ”€ privacy/              # Privacy protection modules
โ”‚   โ”œโ”€โ”€ anonymizer.py
โ”‚   โ””โ”€โ”€ differential_privacy.py
โ”œโ”€โ”€ templates/            # Pre-built schemas
โ”‚   โ””โ”€โ”€ schema_templates.py
โ””โ”€โ”€ utils/               # Utility functions
    โ”œโ”€โ”€ validators.py
    โ””โ”€โ”€ exporters.py

Dependencies

  • โ€”Gradio 4.44.0: Web interface framework
  • โ€”Pandas 2.1.4: Data manipulation
  • โ€”Faker 20.1.0: Fake data generation
  • โ€”NumPy 1.24.3: Numerical operations
  • โ€”Transformers 4.36.2: AI text generation
  • โ€”PyArrow 14.0.1: Parquet export
  • โ€”OpenPyXL 3.1.2: Excel export

Performance

  • โ€”Generation Speed: ~1,000 records/second
  • โ€”Memory Usage: Optimized for large datasets
  • โ€”Export Speed: Streaming for large files
  • โ€”Concurrent Users: Supports multiple sessions

๐Ÿ“ˆ Use Cases

๐Ÿงช Testing & Development

  • โ€”Unit test data
  • โ€”Integration testing
  • โ€”Performance testing
  • โ€”Load testing scenarios

๐Ÿ“Š Data Science

  • โ€”Model training data
  • โ€”Algorithm testing
  • โ€”Statistical analysis
  • โ€”Research datasets

๐Ÿข Business Applications

  • โ€”CRM testing
  • โ€”ERP system testing
  • โ€”Analytics platform testing
  • โ€”Dashboard development

๐Ÿ”’ Privacy Compliance

  • โ€”GDPR compliance testing
  • โ€”HIPAA compliance testing
  • โ€”Data anonymization
  • โ€”Privacy impact assessments

๐ŸŽฏ Examples

Customer Database

json
{
  "customer_id": 12345,
  "first_name": "John",
  "last_name": "Smith",
  "email": "john.smith@email.com",
  "phone": "(555) 123-4567",
  "address": "123 Main St",
  "city": "New York",
  "country": "United States",
  "age": 28,
  "signup_date": "2024-01-15",
  "lifetime_value": 1250.50
}

E-commerce Transaction

json
{
  "transaction_id": 9876543,
  "customer_id": 12345,
  "product_name": "Wireless Headphones",
  "category": "Electronics",
  "quantity": 1,
  "unit_price": 99.99,
  "total_amount": 99.99,
  "transaction_date": "2024-01-15 14:30:00",
  "payment_method": "Credit Card"
}

๐Ÿ”ง Configuration

Environment Variables

bash
# Optional: Set default seed
DEFAULT_SEED=42

# Optional: Set privacy level
DEFAULT_PRIVACY_LEVEL=medium

# Optional: Set max rows
MAX_ROWS=100000

Custom Templates

Add your own templates by extending SchemaTemplates:

python
@staticmethod
def custom_template() -> Dict[str, Any]:
    return {
        'name': 'Custom Template',
        'description': 'My custom data schema',
        'fields': [
            {
                'name': 'custom_field',
                'type': 'text',
                'subtype': 'name',
                'description': 'Custom field description',
                'constraints': {'null_percentage': 5}
            }
        ]
    }

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

bash
git clone https://github.com/your-username/synthetic-data-generator.git
cd synthetic-data-generator
pip install -r requirements.txt
python app.py

Running Tests

bash
python -m pytest tests/

๐Ÿ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • โ€”Faker for realistic data generation
  • โ€”Gradio for the web interface
  • โ€”Hugging Face for AI models
  • โ€”Pandas for data manipulation

๐Ÿ“ž Support


๐Ÿ‘ค Author

Sherin Joseph Roy

Learn More:

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with โค๏ธ for the data community

Generate realistic data. Protect privacy. Build better applications.