niimpy.preprocessing.application module

niimpy.preprocessing.application.app_count(df, bat, screen, config={})[source]

This function returns the number of times each app group has been used, within the specified timeframe. The app groups are defined as a dictionary within the config variable. Examples of app groups are social media, sports, games, etc. If no mapping is given, a default one will be used. If no resampling window is given, the function sets a 30 min default time window. The function aggregates the duration by user, by app group, by timewindow.

Parameters:
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information. If no data is available, an empty dataframe should be passed.

screen: pandas.DataFrame

Dataframe with the screen information. If no data is available, an empty dataframe should be passed.

config: dict, optional

Dictionary keys containing optional arguments for the computation of scrren information. Keys can be column names, other dictionaries, etc. The functions needs the column name where the data is stored; if none is given, the default name “” will be used. To include information about the resampling window, please include the selected parameters from pandas.DataFrame.resample in a dictionary called resample_args.

Returns:
result: dataframe

Resulting dataframe

niimpy.preprocessing.application.app_duration(df, bat, screen, config=None)[source]

This function returns the duration of use of different app groups, within the specified timeframe. The app groups are defined as a dictionary within the config variable. Examples of app groups are social media, sports, games, etc. If no mapping is given, a default one will be used. If no resampling window is given, the function sets a 30 min default time window. The function aggregates the duration by user, by app group, by timewindow.

Parameters:
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information. If no data is available, an empty dataframe should be passed.

screen: pandas.DataFrame

Dataframe with the screen information. If no data is available, an empty dataframe should be passed.

config: dict, optional

Dictionary keys containing optional arguments for the computation of scrren information. Keys can be column names, other dictionaries, etc. The functions needs the column name where the data is stored; if none is given, the default name “application_name” will be used. To include information about the resampling window, please include the selected parameters from pandas.DataFrame.resample in a dictionary called resample_args.

Returns:
result: dataframe

Resulting dataframe

niimpy.preprocessing.application.classify_app(df, config)[source]

This function is a helper function for other screen preprocessing. The function classifies the screen events into the groups specified by group_map.

Parameters:
df: pandas.DataFrame

Input data frame

config: dict, optional

Dictionary keys containing optional arguments for the computation of screen information. Keys can be column names, other dictionaries, etc. It can contain a dictionary called group_map, which has the mapping to define the app groups. Keys should be the app name, values are the app groups (e.g. ‘my_app’:’my_app_group’)

Returns:
df: dataframe

Resulting dataframe

niimpy.preprocessing.application.extract_features_app(df, bat, screen, features=None)[source]

This function computes and organizes the selected features for application events. The function aggregates the features by user, by app group, by time window. If no time window is specified, it will automatically aggregate the features in 30 mins non-overlapping windows. If no group_map is provided, a default one will be used.

The complete list of features that can be calculated are: app_count, and app_duration.

Parameters:
df: pandas.DataFrame

Input data frame

features: dict, optional

Dictionary keys contain the names of the features to compute. If none is given, all features will be computed.

Returns:
result: dataframe

Resulting dataframe

niimpy.preprocessing.application.group_data(df)[source]

Group the dataframe by a standard set of columns listed in group_by_columns.

niimpy.preprocessing.application.reset_groups(df)[source]

Group the dataframe by a standard set of columns listed in group_by_columns.