<jupyter_start><jupyter_text>Generate synthetic data Generation of synthetic data is required to protect private information. Data will be generated for two aspects of the model: * Synthetic production of converted customer flags* Synthetic customer behaviour in the specified columns Import Libraries and sqlite dB engine<jupyter_code>import numpy as np 
import pandas as pd
import sklearn.datasets as dt 

from sqlalchemy import create_engine
engine = create_engine('sqlite:///../data/orgs_customer_behaviours.db')<jupyter_output><empty_output><jupyter_text>Generate synthetic converted customers<jupyter_code>df_org = pd.read_csv('../data/hd2019.csv', encoding='latin1')
synth_conversion = np.random.choice(['0','1'], len(df_org))
org_column_names = list(df_org.columns)
org_column_names.remove('UNITID')
df_org_unitid = df_org.drop(org_column_names, axis=1)
df_org_unitid.insert(1, 'CONVERTED', synth_conversion)
df_org_data = df_org.merge(df_org_unitid, how='left', on='UNITID')
df_org_data.to_csv('../data/hd2019_convert.csv', index=False)<jupyter_output><empty_output><jupyter_text>Generate synthetic customer behaviour<jupyter_code>behaviour_column_names = ['DID_TRIAL', 'PURCHASED_PREVIOUS_PRODUCT', 'AMOUNT_OF_LICENSES',
                          'TERM_OF_LICENSE', 'HAS_TECH_DEPT', 'AMOUNT_OF_INTERACTIONS_W_SALES',
                          'AMOUNT_OF_CALLS', 'AMOUNT_OF_MESSAGES', 'ENGAGED_WITH_MESSAGING', 
                          'REACHED_NOT_ENGAGED_WITH_MESSAGING', 'ATTENDED_WEBINARS', 'WEBINAR_ATTENDANCE_SIZE']
x, y = dt.make_classification(n_samples=1000, n_features=12, n_informative=6, n_repeated=0, n_redundant=4, random_state=42)
df_x = pd.DataFrame(x)
df_y = pd.DataFrame(y)
df_x.columns = behaviour_column_names
df_y.columns = ['CONVERTED']<jupyter_output><empty_output><jupyter_text>Save data to a sqlite dB for further processing<jupyter_code>df_x.to_sql('synth_customer_behaviour_data', engine, if_exists='replace', index=False)
df_y.to_sql('synth_customer_target_classifier_data', engine, if_exists='replace', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10695443645083932, 'fraction_numerical': 0.011510791366906475, 'mean_word_length': 7.054054054054054, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '584521', 'license': 'MIT', 'n_tokens_mistral': 754, 'n_tokens_neox': 716, 'n_words': 128, 'path': 'src/0_generate_cust_behaviours.ipynb', 'repo_name': 'MiloAlphaKilo/Udacity_DSND_Final_Project', 'size': '2085'}