Skip to main content

Generate strings according to specified characteristics

Project description

SynthGen

Introduction

SynthGen is a string generator that generates name-like strings for synthesising name identifiers.
The main goal for developing SynthGen is to create strings that shares the characteristics of a known population.
This version of SynthGen generates low fidelity sex and ethnicity.

Users can tailor:

Total number of terms to generate: total_strings (int) (1,000)

characteristics related to gender/ethnicity

Proportion of names are unique (not correct yet): unique_percentage (int) (0.5)
Proportion of gender: gender_settings (dict) {'Male': 0.4, 'Female': 0.6}
Proportion of Strings overlapped by gender: gender_overlap_percentage (int) (0.15)
Proportion of ethnicity: ethnicity_settings (dict) {'White': 0.81, 'Asian': 0.096, 'Black': 0.042, 'Mixed': 0.03, 'Other': 0.022}
Proportion of Strings overlapped by ethnicity: ethnicity_overlap_percentages (dict) {('White', 'Black'): 0.1, ('White', 'Asian'): 0.05, ('White', 'Other'): 0.1}

String related characteristics:

string_settings = {
'lengths': [4, 5, 6, 7], # Specify lengths
'length_probabilities': [0.15, 0.3, 0.4, 0.15], # Specify length probabilities
'num_terms_range': [1, 2, 3], # Specify number of terms range
'num_terms_probabilities': [0.2, 0.6, 0.2] # Specify number of terms probabilities
}

Future direction - 1

Other string characteristics will be introduced to tailor, such as:

  • apostrophes, hyphens, non-ISO characters
  • vowel-consonant ratios

Uniqueness of terms will be a key goal to be retained, by gender and ethnicity.

Future direction - 2

To implement a insight tool to generate settings based on the loaded dataframe, and generate strings that match the characteristics of the loaded dataset.


Current work-around looks like:

uniqueness_requirements = { ('White', 'Male'): 0.85, ('White', 'Female'): 0.80, ('Black', 'Male'): 0.90, ('Black', 'Female'): 0.75, # Add more combinations as needed }

df = pd.read_csv('output_from_SynthGen.csv') grouped_df = df.groupby(['Ethnicity', 'Gender'])

for group, group_data in grouped_df: # Get the desired uniqueness for the current group from the dictionary desired_uniqueness = uniqueness_requirements.get(group, 0.8) # Default to 0.8 if not specified

# Calculate the number of unique names needed for the group based on desired uniqueness
total_names = len(group_data)
unique_names_needed = int(desired_uniqueness * total_names)

# Apply your sampling technique to ensure the desired level of uniqueness
# Replace this with your actual sampling logic
sampled_data = group_data.sample(unique_names_needed)

# Append the sampled data to the subsample DataFrame
subsample_df = subsample_df.append(sampled_data)

subsample_df.to_csv('subsampled_data.csv', index=False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

synthgen-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

synthgen-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file synthgen-0.1.1.tar.gz.

File metadata

  • Download URL: synthgen-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.5 Windows/10

File hashes

Hashes for synthgen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9638de7975d4dc12d620146278b6f048f63237445924c8f457f9ff6d4484c0fc
MD5 ece0cb759cd776e8d644ead3f56ac626
BLAKE2b-256 107f6c843807d484e4bfe2af932f07240ee020a81229aad6450d5d48b02b27de

See more details on using hashes here.

File details

Details for the file synthgen-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: synthgen-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.5 Windows/10

File hashes

Hashes for synthgen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2b0d74fb69d46fd89bdd03632f780524ad8b15588eb706c97df0634c0ded095
MD5 37d97376d7491f769ad30d78d57776c2
BLAKE2b-256 c55916952fa6645615b01230205725b561d083a7b8d65e7aa8ebc0441c78329d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page