From 636b64c61af769090dcc0189c20c76904949042e Mon Sep 17 00:00:00 2001 From: JulioV Date: Mon, 5 Apr 2021 11:25:00 -0400 Subject: [PATCH] Revert "Added more keyboard features." This reverts commit 94c72e3172357b1b32f8c8be25c1c99ba4e25f76. --- config.yaml | 8 +--- src/features/phone_keyboard/rapids/main.py | 55 ---------------------- 2 files changed, 1 insertion(+), 62 deletions(-) delete mode 100644 src/features/phone_keyboard/rapids/main.py diff --git a/config.yaml b/config.yaml index b3509a0a..f2997bca 100644 --- a/config.yaml +++ b/config.yaml @@ -211,13 +211,7 @@ PHONE_DATA_YIELD: # See https://www.rapids.science/latest/features/phone-keyboard/ PHONE_KEYBOARD: CONTAINER: keyboard - PROVIDERS: - RAPIDS: - COMPUTE: True - FEATURES: ["sessioncount","avereageinterkeydelay","changeintextlengthlessthanminusone","changeintextlengthequaltominusone","changeintextlengthequaltoone","changeintextlengthmorethanone","maxtextlength","lastmessagelength"] - SRC_FOLDER: "rapids" # inside src/features/phone_keyboard - SRC_LANGUAGE: "python" - SRC_SCRIPT: src/features/phone_keyboard/rapids/main.py + PROVIDERS: # None implemented yet but this sensor can be used in PHONE_DATA_YIELD # See https://www.rapids.science/latest/features/phone-light/ PHONE_LIGHT: diff --git a/src/features/phone_keyboard/rapids/main.py b/src/features/phone_keyboard/rapids/main.py deleted file mode 100644 index 87da47d0..00000000 --- a/src/features/phone_keyboard/rapids/main.py +++ /dev/null @@ -1,55 +0,0 @@ -import pandas as pd -import numpy as np - -def rapids_features(sensor_data_files, time_segment, provider, filter_data_by_segment, *args, **kwargs): - - keyboard_data = pd.read_csv(sensor_data_files["sensor_data"]) - requested_features = provider["FEATURES"] - - # name of the features this function can compute - base_features_names = ["sessioncount","avereageinterkeydelay","changeintextlengthlessthanminusone","changeintextlengthequaltominusone","changeintextlengthequaltoone","changeintextlengthmorethanone","maxtextlength","lastmessagelength"] - - # the subset of requested features this function can compute - features_to_compute = list(set(requested_features) & set(base_features_names)) - - keyboard_features = pd.DataFrame(columns=["local_segment"] + features_to_compute) - if not keyboard_data.empty: - keyboard_data = filter_data_by_segment(keyboard_data, time_segment) - - if not keyboard_data.empty: - keyboard_features = pd.DataFrame() - - keyboard_data["keyboardStrokeDuration"] = keyboard_data['timestamp'].shift(-1) - keyboard_data['timestamp'] - keyboard_data["sessionStart"] = keyboard_data["keyboardStrokeDuration"].apply(lambda x: 1 if x>=5000 else 0) - keyboard_data["sessionNumber"] = keyboard_data["sessionStart"].cumsum() - keyboard_data["changeInText"] = keyboard_data["current_text"].str.len() - 2 - keyboard_data['before_text'].str.len() - keyboard_data["currentTextLength"] = keyboard_data["current_text"].str.len() - 2 - - if "sessioncount" in features_to_compute: - keyboard_features['sessioncount'] = keyboard_data.groupby(['local_segment'])['sessionStart'].sum() - - if "averageinterkeydelay" in features_to_compute: - keyboard_features['averageinterkeydelay'] = keyboard_data[keyboard_data['sessionStart'] == 0].groupby(['local_segment','sessionNumber'])['duration'].mean().reset_index().groupby(['local_segment'])['duration'].mean() - - if "changeintextlengthlessthanminusone" in features_to_compute: - keyboard_features['changeintextlengthlessthanminusone'] = keyboard_data[keyboard_data.changeInText < -1].groupby(['local_segment','sessionNumber'])['changeInText'].count().reset_index().groupby(['local_segment'])['changeInText'].count() - - if "changeintextlengthequaltominusone" in features_to_compute: - keyboard_features['changeintextlengthequaltominusone'] = keyboard_data[keyboard_data.changeInText == -1].groupby(['local_segment','sessionNumber'])['changeInText'].count().reset_index().groupby(['local_segment'])['changeInText'].count() - - if "changeintextlengthequaltoone" in features_to_compute: - keyboard_features['changeintextlengthequaltoone'] = keyboard_data[keyboard_data.changeInText == 1].groupby(['local_segment','sessionNumber'])['changeInText'].count().reset_index().groupby(['local_segment'])['changeInText'].count() - - if "changeintextlengthmorethanone" in features_to_compute: - keyboard_features['changeintextlengthmorethanone'] = keyboard_data[keyboard_data.changeInText > 1].groupby(['local_segment','sessionNumber'])['changeInText'].count().reset_index().groupby(['local_segment'])['changeInText'].count() - - if "maxtextlength" in features_to_compute: - keyboard_features["maxtextlength"] = keyboard_data[keyboard_data.currentTextLength > 0].groupby(['local_segment','sessionNumber'])['currentTextLength'].max().reset_index().groupby(['local_segment'])['currentTextLength'].mean() - - if "lastmessagelength" in features_to_compute: - keyboard_data_copy = keyboard_data[['local_segment','sessionNumber','currentTextLength']].copy() - keyboard_features["lastmessagelength"] = keyboard_data_copy[keyboard_data_copy.currentTextLength > 0].groupby(['local_segment','sessionNumber'])['currentTextLength'].mean().reset_index().groupby(['local_segment'])['currentTextLength'].mean() - - keyboard_features = keyboard_features.reset_index() - - return keyboard_features