import pandas as pd
import numpy as np
import random
import os

# Create directory for dataset
os.makedirs("data", exist_ok=True)

# Generate synthetic hiring data
np.random.seed(42)
n_samples = 10000
experience = np.random.randint(1, 20, n_samples)  # Years of experience
education = np.random.randint(1, 5, n_samples)    # Education level (1-4)
gender = np.random.choice(['M', 'F'], n_samples)  # Protected attribute

# Simulate biased hiring (males more likely hired with less experience)
hired = []
for i in range(n_samples):
    if gender[i] == 'M':
        prob = 0.8 if experience[i] > 5 else 0.4
    else:
        prob = 0.6 if experience[i] > 10 else 0.2
    hired.append(1 if random.random() < prob else 0)

# Create DataFrame
data = {
    'experience': experience,
    'education': education,
    'gender': gender,
    'hired': hired
}
df = pd.DataFrame(data)
csv_path = "data/bias.csv"
df.to_csv(csv_path, index=False)
print(f"Created {csv_path} with {len(df)} entries.")

# Print sample
print("\nSample of bias.csv:")
print(df.head())
