Add a method to get communication features.

rapids
junos 2021-08-19 17:32:02 +02:00
parent 5be3e82797
commit 93f136b080
3 changed files with 8 additions and 3 deletions

View File

@ -37,7 +37,7 @@ FEATURES_SMS = (
# "no_received_ratio", "no_sent_ratio",
# "no_contacts"]
FEATURES_CONTACT = [
FEATURES_CALLS_SMS_PROP = [
"proportion_calls_all",
"proportion_calls_incoming",
"proportion_calls_outgoing",
@ -45,6 +45,8 @@ FEATURES_CONTACT = [
"proportion_calls_missed_sms_received",
]
FEATURES_CALLS_SMS_ALL = FEATURES_CALLS + FEATURES_SMS + FEATURES_CALLS_SMS_PROP
def get_call_data(usernames: Collection) -> pd.DataFrame:
"""

View File

@ -69,6 +69,10 @@ class SensorFeatures:
if feature_names == "all":
feature_names = proximity.FEATURES_PROXIMITY
return self.df_proximity_counts[feature_names]
elif data_type == "communication":
if feature_names == "all":
feature_names = communication.FEATURES_CALLS_SMS_ALL
return self.df_calls_sms[feature_names]
else:
raise KeyError("This data type has not been implemented.")

View File

@ -88,6 +88,5 @@ class CallsFeatures(unittest.TestCase):
self.features_call_sms = calls_sms_features(self.calls, self.sms)
self.assertIsInstance(self.features_call_sms, pd.DataFrame)
self.assertCountEqual(
self.features_call_sms.columns.to_list(),
FEATURES_CALLS + FEATURES_SMS + FEATURES_CONTACT,
self.features_call_sms.columns.to_list(), FEATURES_CALLS_SMS_ALL
)