Created
October 29, 2023 19:34
-
-
Save samvardhan777/6ca76a5002e3266f3d890be49ced4c8f to your computer and use it in GitHub Desktop.
faker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _ in range(num_customers): | |
customer_name = fake.name() | |
account_name = fake.iban() | |
# Generate the initial profile for the customer | |
profile_states, _ = model.sample(transactions_per_customer) | |
profiles = [customer_profiles[state] for state in profile_states.ravel()] | |
for idx, profile in enumerate(profiles): | |
profile_index = customer_profiles.index(profile) | |
transaction_emission_probs = emission_probabilities[profile_index] | |
transaction_type = np.random.choice(['withdrawal', 'deposit'], p=transaction_emission_probs) | |
transaction_time = fake.date_time_this_year() | |
transaction_amount = np.random.randint(100, 1000) if transaction_type == 'deposit' else np.random.randint(20, 500) | |
transaction_city = fake.city() | |
transaction_category = np.random.choice(transaction_categories) | |
transaction_ref_id = f"TXN-{fake.unique.random_number(digits=8)}-{idx}" | |
transaction = { | |
'customer_name': customer_name, | |
'account_name': account_name, | |
'profile': profile, | |
'transaction_type': transaction_type, | |
'Amount(United States Dollar)': transaction_amount, | |
'time_transaction': transaction_time, | |
'transaction_city': transaction_city, | |
'transaction_category': transaction_category, | |
'transaction_ref_id': transaction_ref_id | |
} | |
transactions.append(transaction) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment