diff --git a/config.yaml b/config.yaml index c1f13209..7ee17e54 100644 --- a/config.yaml +++ b/config.yaml @@ -113,7 +113,7 @@ PHONE_APPLICATIONS_FOREGROUND: COMPUTE: False INCLUDE_EPISODE_FEATURES: False SINGLE_CATEGORIES: ["all", "email"] - OWN_CATEGORIES: + CUSTOM_CATEGORIES: social_media: ['com.google.android.youtube','com.snapchat.android','com.instagram.android','com.zhiliaoapp.musically','com.facebook.katana'] dating: ['com.tinder','com.relance.happycouple','com.kiwi.joyride'] MULTIPLE_CATEGORIES: diff --git a/docs/features/phone-applications-foreground.md b/docs/features/phone-applications-foreground.md index 92b3e605..7ff274e0 100644 --- a/docs/features/phone-applications-foreground.md +++ b/docs/features/phone-applications-foreground.md @@ -36,7 +36,7 @@ Parameters description for `[PHONE_APPLICATIONS_FOREGROUND][PROVIDERS][RAPIDS]`: |`[INCLUDE_EPISODE_FEATURES]`| Set to `True` to extract application episode features as well from the `RAPIDS` provider| |`[FEATURES]` | Features to be computed, see table below |`[SINGLE_CATEGORIES]` | An array of app categories to be *included* in the feature extraction computation. The special keyword `all` represents a category with all the apps from each participant. By default we use the category catalogue pointed by `[APPLICATION_CATEGORIES][CATALOGUE_FILE]` (see the Sensor parameters description table above) -|`[OWN_CATEGORIES]` | An array of collections representing your own app categories. They key of each element is the name of the in-house category and the value is an array of the package names (apps) included in that category. +|`[CUSTOM_CATEGORIES]` | An array of collections representing your own app categories. They key of each element is the name of the in-house category and the value is an array of the package names (apps) included in that category. |`[MULTIPLE_CATEGORIES]` | An array of collections representing meta-categories (a group of categories). They key of each element is the name of the `meta-category` and the value is an array of member app categories. By default we use the category catalogue pointed by `[APPLICATION_CATEGORIES][CATALOGUE_FILE]` (see the Sensor parameters description table above) |`[SINGLE_APPS]` | An array of apps to be *included* in the feature extraction computation. Use their package name (e.g. `com.google.android.youtube`) or the reserved keyword `top1global` (the most used app by a participant over the whole monitoring study) |`[EXCLUDED_CATEGORIES]` | An array of app categories to be *excluded* from the feature extraction computation. By default we use the category catalogue pointed by `[APPLICATION_CATEGORIES][CATALOGUE_FILE]` (see the Sensor parameters description table above) diff --git a/src/features/phone_applications_foreground/rapids/main.py b/src/features/phone_applications_foreground/rapids/main.py index c1d1f409..8fe4594e 100644 --- a/src/features/phone_applications_foreground/rapids/main.py +++ b/src/features/phone_applications_foreground/rapids/main.py @@ -68,11 +68,11 @@ def process_app_features(data, requested_features, time_segment, provider, filte for mcategory_name, mcategory_content in provider["MULTIPLE_CATEGORIES"].items(): if len(mcategory_content) > 0 and mcategory_name not in excluded_categories: multiple_categories[mcategory_name] = mcategory_content - own_categories = {} - if isinstance(provider["OWN_CATEGORIES"], dict): - for owncategory_name, owncategory_content in provider["OWN_CATEGORIES"].items(): + custom_categories = {} + if isinstance(provider["CUSTOM_CATEGORIES"], dict): + for owncategory_name, owncategory_content in provider["CUSTOM_CATEGORIES"].items(): if len(owncategory_content) > 0 and owncategory_name not in excluded_categories: - own_categories[owncategory_name] = owncategory_content + custom_categories[owncategory_name] = owncategory_content single_apps = provider["SINGLE_APPS"] single_categories = list(set(single_categories) - set(excluded_categories)) single_apps = list(set(single_apps) - set(excluded_apps)) @@ -84,7 +84,7 @@ def process_app_features(data, requested_features, time_segment, provider, filte # exclude apps in the excluded_apps list data = data[~data["package_name"].isin(excluded_apps)] - features = pd.DataFrame(columns=["local_segment"] + ["".join(feature) for feature in itertools.product(requested_features, single_categories + list(own_categories.keys()) + list(multiple_categories.keys()) + single_apps)]) + features = pd.DataFrame(columns=["local_segment"] + ["".join(feature) for feature in itertools.product(requested_features, single_categories + list(custom_categories.keys()) + list(multiple_categories.keys()) + single_apps)]) if not data.empty: # deep copy the data for the top1global computation data_global = data.copy() @@ -102,7 +102,7 @@ def process_app_features(data, requested_features, time_segment, provider, filte filtered_data = data[data["genre"].isin([sc])] features = compute_features(filtered_data, sc, requested_features, features, time_segment) # own categories - for owncategory_name, owncategory_content in own_categories.items(): + for owncategory_name, owncategory_content in custom_categories.items(): filtered_data = data[data["package_name"].isin(owncategory_content)] features = compute_features(filtered_data, owncategory_name, requested_features, features, time_segment) # multiple categories @@ -142,5 +142,5 @@ def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_se episodes_features = process_app_features(episode_data, requested_episodes_features, time_segment, provider, filter_data_by_segment) features = pd.merge(episodes_features, features, how='outer', on='local_segment') - + return features \ No newline at end of file diff --git a/tools/config.schema.yaml b/tools/config.schema.yaml index 7fc372a0..6cc5453f 100644 --- a/tools/config.schema.yaml +++ b/tools/config.schema.yaml @@ -346,7 +346,7 @@ properties: uniqueItems: True items: type: string - OWN_CATEGORIES: + CUSTOM_CATEGORIES: type: ["null", object] additionalProperties: type: array