<jupyter_start><jupyter_text>Quick start guide  https://docs.featuretools.com/minute-quick-start **Deep Feature Synthesis (DFS) to perform automated feature engineering.**<jupyter_code>import featuretools as ft
# mock data
data = ft.demo.load_mock_customer()<jupyter_output><empty_output><jupyter_text>**Prepare data**According to the documentation, there are 3 tables in this dataset. (but in fact there are 4 tables)In Featuretools, each table is `entity`.- **customers**: unique customers who had sessions- **sessions**: unique sessions and associated attributes- **transactions**: list of events in this session<jupyter_code>type(data)
for ind, ent in enumerate(data.keys()):
    print('Entity {} : {}'.format(ind + 1, ent))
customers_df = data['customers']
customers_df
sessions_df = data['sessions']
sessions_df.sample(5)
transactions_df = data['transactions']
transactions_df.sample(5)<jupyter_output><empty_output><jupyter_text>**First, specify a dictionary with all the entities in the dataset.**<jupyter_code>entities = {
    "customers" : (customers_df, "customer_id"),
    "sessions" : (sessions_df, "session_id", "session_start"),
    "transactions" : (transactions_df, "transaction_id", "transaction_time")
}<jupyter_output><empty_output><jupyter_text>**Second, specify how the entities are related. When 2 two entities have a one-to-many relationship, we call the “one” enitity, the “parent entity”. A relationship between a parent and child is defined like this:**```(parent_entity, parent_variable, child_entity, child_variable)``` Two relationships in the dataset<jupyter_code>relationships = [("sessions", "session_id", "transactions", "session_id"),
                 ("customers", "customer_id", "sessions", "customer_id")]<jupyter_output><empty_output><jupyter_text>Better convenient API for *entities* and *relationships*:  `EntitySet` : https://docs.featuretools.com/loading_data/using_entitysets.html  **Run Deep Feature Synthesis**Minimal input to DFS- a set of entities- a list of relationships- "target_entity"-> output : - feature matrix - the corresponding list of feature definitions<jupyter_code>feature_matrix_customers, features_defs = ft.dfs(entities=entities, 
                                                 relationships=relationships,
                                                 target_entity="customers")
feature_matrix_customers
print('Original number of features : {}'.format(customers_df.shape[1]))<jupyter_output>Original number of features : 3<jupyter_text>60 + new features createad to describe customers ! **Try with another target entity**<jupyter_code>feature_matrix_sessions, features_defs = ft.dfs(entities=entities,
                                                relationships=relationships,
                                                target_entity="sessions")
feature_matrix_sessions.head(5)
print('Original number of features : {}'.format(sessions_df.shape[1]))<jupyter_output>Original number of features : 4
{'fraction_non_alphanumeric': 0.11099899091826437, 'fraction_numerical': 0.004372687521022536, 'mean_word_length': 4.675572519083969, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 24, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '321339', 'license': 'Unlicense', 'n_tokens_mistral': 837, 'n_tokens_neox': 819, 'n_words': 223, 'path': 'quick-starts/quick-starts.ipynb', 'repo_name': 'xinbinhuang/feature-selection', 'size': '2973'}