niimpy.preprocessing.screen module

niimpy.preprocessing.screen.duration_util_screen(df)[source]

This function is a helper function for other screen preprocessing. The function computes the duration of an event, based on the classification function event_classification_screen.

Parameters
df: pandas.DataFrame

Input data frame

Returns
df: dataframe

Resulting dataframe

niimpy.preprocessing.screen.event_classification_screen(df, config)[source]

This function is a helper function for other screen preprocessing. The function classifies the screen events into four transition types: on, off, in use, and undefined, based on the screen events recorded. For example, if two consecutive events are 0 and 3, there has been a transition from off to unlocked, i.e. the phone has been unlocked and the events will be classified into the “use” transition.

Parameters
df: pandas.DataFrame

Input data frame

config: dict

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 employed by Aware Framework 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
df: dataframe

Resulting dataframe

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

This function computes and organizes the selected features for screen events that have been recorded using Aware Framework. The function aggregates the features by user, by time window. If no time window is specified, it will automatically aggregate the features in 30 mins non-overlapping windows.

The complete list of features that can be calculated are: screen_off, screen_count, screen_duration, screen_duration_min, screen_duration_max, screen_duration_median, screen_duration_mean, screen_duration_std, and screen_first_unlock.

Parameters
df: pandas.DataFrame

Input data frame

features: dict

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

Returns
computed_features: dataframe

Resulting dataframe

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

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

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

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

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

This function returns the number of times, within the specified timeframe, when the screen has turned off, turned on, and been in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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
df: dataframe

Resulting dataframe

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

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_duration_max(df, bat, config=None)[source]

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_duration_mean(df, bat, config=None)[source]

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_duration_median(df, bat, config=None)[source]

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_duration_min(df, bat, config=None)[source]

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_duration_std(df, bat, config=None)[source]

This function returns the duration (in seconds) of each transition, within the specified timeframe. The transitions are off, on, and in use. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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.screen.screen_first_unlock(df, bat, config)[source]

This function returns the first time the phone was unlocked each day. The data is aggregated by user, by day.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework will be used.

Returns
result: dataframe

Resulting dataframe

niimpy.preprocessing.screen.screen_off(df, bat, config)[source]

This function returns the timestamps, within the specified timeframe, when the screen has turned off. If there is no specified timeframe, the function sets a 30 min default time window. The function aggregates this number by user, by timewindow.

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict, optional

Dictionary keys containing optional arguments for the computation of scrren information. Keys can be column names, other dictionaries, etc.

Returns
df: dataframe

Resulting dataframe

niimpy.preprocessing.screen.util_screen(df, bat, config)[source]

This function is a helper function for all other screen preprocessing. The function has the option to merge information from the battery sensors to include data when the phone is shut down. The function also detects the missing datapoints (i.e. not allowed transitions like ON to ON).

Parameters
df: pandas.DataFrame

Input data frame

bat: pandas.DataFrame

Dataframe with the battery information

config: dict

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 employed by Aware Framework 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
df: dataframe

Resulting dataframe