From 35638f2a2d625c3d9cb80ecd670307ee7a0be2ec Mon Sep 17 00:00:00 2001 From: ajoubrel-ensae Date: Sun, 31 Mar 2024 16:34:55 +0000 Subject: [PATCH] =?UTF-8?q?Passage=20=C3=A0=20demande=20input=20=C3=A0=20b?= =?UTF-8?q?oucle=20sur=20activite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 4_Descriptive_Statistics.py | 104 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 51 deletions(-) diff --git a/4_Descriptive_Statistics.py b/4_Descriptive_Statistics.py index eb67195..45af7ee 100644 --- a/4_Descriptive_Statistics.py +++ b/4_Descriptive_Statistics.py @@ -21,54 +21,56 @@ companies = {'musee' : ['1', '2', '3', '4'], # , '101' 'musique' : ['10', '11', '12', '13', '14']} -type_of_activity = input('Choisissez le type de compagnie : sport ? musique ? musee ?') -list_of_comp = companies[type_of_activity] - -# Load files -customer, campaigns_kpi, campaigns_brut, tickets, products, targets = load_files(list_of_comp) - -# Identify anonymous customer for each company and remove them from our datasets -outlier_list = outlier_detection(tickets, list_of_comp) - -# Identify valid customer (customer who bought tickets after starting date or received mails after starting date) -customer_valid_list = valid_customer_detection(products, campaigns_brut) - -databases = [customer, campaigns_kpi, campaigns_brut, tickets, products] - -for dataset in databases: - dataset['customer_id'] = dataset['customer_id'].apply(lambda x: remove_elements(x, outlier_list))# remove outlier - dataset = dataset[dataset['customer_id'].isin(customer_valid_list)] # keep only valid customer - #print(f'shape of {dataset} : ', dataset.shape) - -# Identify customer who bought during the period of y -customer_target_period = identify_purchase_during_target_periode(products) -customer['has_purchased_target_period'] = np.where(customer['customer_id'].isin(customer_target_period), 1, 0) - -# Generate graph and automatically saved them in the bucket -compute_nb_clients(customer, type_of_activity) - -#maximum_price_paid(customer, type_of_activity) - -target_proportion(customer, type_of_activity) - -mailing_consent(customer, type_of_activity) - -mailing_consent_by_target(customer) - -gender_bar(customer, type_of_activity) - -country_bar(customer, type_of_activity) - -lazy_customer_plot(campaigns_kpi, type_of_activity) - -campaigns_effectiveness(customer, type_of_activity) - -sale_dynamics(products, campaigns_brut, type_of_activity) - -tickets_internet(tickets, type_of_activity) - -already_bought_online(tickets, type_of_activity) - -box_plot_price_tickets(tickets, type_of_activity) - -target_description(targets, type_of_activity) \ No newline at end of file +# type_of_activity = input('Choisissez le type de compagnie : sport ? musique ? musee ?') +for type_of_activity in ['musee', 'sport', 'musique'] : + + list_of_comp = companies[type_of_activity] + + # Load files + customer, campaigns_kpi, campaigns_brut, tickets, products, targets = load_files(list_of_comp) + + # Identify anonymous customer for each company and remove them from our datasets + outlier_list = outlier_detection(tickets, list_of_comp) + + # Identify valid customer (customer who bought tickets after starting date or received mails after starting date) + customer_valid_list = valid_customer_detection(products, campaigns_brut) + + databases = [customer, campaigns_kpi, campaigns_brut, tickets, products] + + for dataset in databases: + dataset['customer_id'] = dataset['customer_id'].apply(lambda x: remove_elements(x, outlier_list))# remove outlier + dataset = dataset[dataset['customer_id'].isin(customer_valid_list)] # keep only valid customer + #print(f'shape of {dataset} : ', dataset.shape) + + # Identify customer who bought during the period of y + customer_target_period = identify_purchase_during_target_periode(products) + customer['has_purchased_target_period'] = np.where(customer['customer_id'].isin(customer_target_period), 1, 0) + + # Generate graph and automatically saved them in the bucket + compute_nb_clients(customer, type_of_activity) + + #maximum_price_paid(customer, type_of_activity) + + target_proportion(customer, type_of_activity) + + mailing_consent(customer, type_of_activity) + + mailing_consent_by_target(customer) + + gender_bar(customer, type_of_activity) + + country_bar(customer, type_of_activity) + + lazy_customer_plot(campaigns_kpi, type_of_activity) + + campaigns_effectiveness(customer, type_of_activity) + + sale_dynamics(products, campaigns_brut, type_of_activity) + + tickets_internet(tickets, type_of_activity) + + already_bought_online(tickets, type_of_activity) + + box_plot_price_tickets(tickets, type_of_activity) + + target_description(targets, type_of_activity) \ No newline at end of file