From fb682bc76351b683cb5a935bc4ab28369c3d73d6 Mon Sep 17 00:00:00 2001 From: Mohammad Amin Date: Tue, 17 Oct 2023 12:31:09 +0330 Subject: [PATCH] update: updated the act_param usage! the act_param should be a dictionary as input from now on. --- tc_core_analyzer_lib/assess_engagement.py | 85 ++++++++++++----------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/tc_core_analyzer_lib/assess_engagement.py b/tc_core_analyzer_lib/assess_engagement.py index 0dc09dd..02dd02a 100644 --- a/tc_core_analyzer_lib/assess_engagement.py +++ b/tc_core_analyzer_lib/assess_engagement.py @@ -95,35 +95,36 @@ def compute( containing a list of all account names belonging to engagement category * - act_param : list[int] + act_param : dict[str, int] parameters for activity types: - INT_THR : int - minimum number of interactions to be active - UW_DEG_THR : int - minimum number of connections to be active - EDGE_STR_THR : int - minimum number of interactions for connected - UW_THR_DEG_THR : int - minimum number of accounts for connected - CON_T_THR : int - time period to assess consistently active - CON_O_THR : int - times to be active within CON_T_THR to be - consistently active - VITAL_T_THR : int - time period to assess for vital - VITAL_O_THR : int - times to be connected within VITAL_T_THR to be vital - PAUSED_T_THR : int - time period to remain paused - STILL_T_THR : int - time period to assess for still active - STILL_O_THR : int - times to be active within STILL_T_THR to be still active - DROP_H_THR : int - time periods in the past to have been newly active - DROP_I_THR : int - time periods to have been inactive + keys are listed below + - INT_THR : int + minimum number of interactions to be active + - UW_DEG_THR : int + minimum number of connections to be active + - EDGE_STR_THR : int + minimum number of interactions for connected + - UW_THR_DEG_THR : int + minimum number of accounts for connected + - CON_T_THR : int + time period to assess consistently active + - CON_O_THR : int + times to be active within CON_T_THR to be + consistently active + - VITAL_T_THR : int + time period to assess for vital + - VITAL_O_THR : int + times to be connected within VITAL_T_THR to be vital + - PAUSED_T_THR : int + time period to remain paused + - STILL_T_THR : int + time period to assess for still active + - STILL_O_THR : int + times to be active within STILL_T_THR to be still active + - DROP_H_THR : int + time periods in the past to have been newly active + - DROP_I_THR : int + time periods to have been inactive Returns: --------- @@ -141,10 +142,10 @@ def compute( # # # THRESHOLD INTERACTIONS # # # thr_ind, thr_uw_deg, thr_uw_thr_deg, graph = thr_int( int_mat, - act_param[0], - act_param[1], - act_param[5], - act_param[6], + act_param["INT_THR"], + act_param["UW_DEG_THR"], + act_param["EDGE_STR_THR"], + act_param["UW_THR_DEG_THR"], activities=self.activities, ignore_axis_0_activities=self.activities_ignore_0_axis, ignore_axis_1_activities=self.activities_ignore_1_axis, @@ -161,13 +162,13 @@ def compute( # # # CONSISTENTLY ACTIVE # # # all_consistent = assess_consistent( - all_active, w_i, act_param[3], act_param[4], WINDOW_D, all_consistent + all_active, w_i, act_param["CON_T_THR"], act_param["CON_O_THR"], WINDOW_D, all_consistent ) # # # VITAL # # # all_vital = assess_vital( - all_connected, w_i, act_param[7], act_param[8], WINDOW_D, all_vital + all_connected, w_i, act_param["VITAL_T_THR"], act_param["VITAL_O_THR"], WINDOW_D, all_vital ) # # # STILL ACTIVE # # # @@ -176,8 +177,8 @@ def compute( all_new_active, all_active, w_i, - act_param[9], - act_param[10], + act_param["STILL_T_THR"], + act_param["STILL_O_THR"], WINDOW_D, all_still_active, ) @@ -188,8 +189,8 @@ def compute( all_new_active, all_active, w_i, - act_param[11], - act_param[12], + act_param["DROP_H_THR"], + act_param["DROP_I_THR"], WINDOW_D, all_dropped, ) @@ -208,7 +209,7 @@ def compute( all_active, w_i, WINDOW_D, - act_param[2], + act_param["PAUSED_T_THR"], all_new_active, all_unpaused, all_returned, @@ -245,7 +246,7 @@ def compute( rem_new_disengaged[str(w_i)], all_disengaged_were_vital[str(w_i)], ) = assess_overlap( - all_new_disengaged, all_vital, w_i, (act_param[2] + 1) * WINDOW_D + all_new_disengaged, all_vital, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D ) # assess who of the remaining disengaged accounts @@ -254,7 +255,7 @@ def compute( rem_new_disengaged[str(w_i)], all_disengaged_were_consistently_active[str(w_i)], ) = assess_overlap( - rem_new_disengaged, all_consistent, w_i, (act_param[2] + 1) * WINDOW_D + rem_new_disengaged, all_consistent, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D ) # assess who of the remaining disengaged accounts @@ -263,7 +264,7 @@ def compute( rem_new_disengaged[str(w_i)], all_disengaged_were_newly_active[str(w_i)], ) = assess_overlap( - rem_new_disengaged, all_new_active, w_i, (act_param[2] + 1) * WINDOW_D + rem_new_disengaged, all_new_active, w_i, (act_param["PAUSED_T_THR"] + 1) * WINDOW_D ) else: all_disengaged_were_vital[str(w_i)] = set()