Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update action param type #19

Merged
merged 3 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 62 additions & 42 deletions tc_core_analyzer_lib/assess_engagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
---------
Expand All @@ -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,
Expand All @@ -161,13 +162,23 @@ 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 # # #
Expand All @@ -176,8 +187,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,
)
Expand All @@ -188,8 +199,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,
)
Expand All @@ -208,7 +219,7 @@ def compute(
all_active,
w_i,
WINDOW_D,
act_param[2],
act_param["PAUSED_T_THR"],
all_new_active,
all_unpaused,
all_returned,
Expand Down Expand Up @@ -245,7 +256,10 @@ 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
Expand All @@ -254,7 +268,10 @@ 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
Expand All @@ -263,7 +280,10 @@ 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()
Expand Down
95 changes: 30 additions & 65 deletions tc_core_analyzer_lib/tests/integration/test_active_members.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,39 +45,21 @@ def test_no_active():
# window index
w_i = 0

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active

# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2

# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

activities = [
DiscordActivity.Reaction,
Expand Down Expand Up @@ -165,38 +147,21 @@ def test_single_active():
WINDOW_D = 7
# window index
w_i = 0

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

activities = [
DiscordActivity.Reaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,21 @@ def test_all_active_fourteen_period():
so we should have the users as active for the interaction matrix
and not the window_d period here
"""
INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

analytics_length = 14
all_joined_day = dict(
Expand Down
46 changes: 15 additions & 31 deletions tc_core_analyzer_lib/tests/integration/test_consistently_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,21 @@ def test_two_consistently_active():
}
memberactivities = activity_dict.keys()

INT_THR = 1 # minimum number of interactions to be active
UW_DEG_THR = 1 # minimum number of accounts interacted with to be active
PAUSED_T_THR = 1 # time period to remain paused
CON_T_THR = 4 # time period to be consistent active
CON_O_THR = 3 # time period to be consistent active
EDGE_STR_THR = 5 # minimum number of interactions for connected
UW_THR_DEG_THR = 5 # minimum number of accounts for connected
VITAL_T_THR = 4 # time period to assess for vital
VITAL_O_THR = 3 # times to be connected within VITAL_T_THR to be vital
STILL_T_THR = 2 # time period to assess for still active
STILL_O_THR = 2 # times to be active within STILL_T_THR to be still active
# time periods into the past (history) to be newly active for computing dropped
DROP_H_THR = 2
# consecutive time periods into the past to have not been active for computing
DROP_I_THR = 1

act_param = [
INT_THR,
UW_DEG_THR,
PAUSED_T_THR,
CON_T_THR,
CON_O_THR,
EDGE_STR_THR,
UW_THR_DEG_THR,
VITAL_T_THR,
VITAL_O_THR,
STILL_T_THR,
STILL_O_THR,
DROP_H_THR,
DROP_I_THR,
]
act_param = {
"INT_THR": 1,
"UW_DEG_THR": 1,
"PAUSED_T_THR": 1,
"CON_T_THR": 4,
"CON_O_THR": 3,
"EDGE_STR_THR": 5,
"UW_THR_DEG_THR": 5,
"VITAL_T_THR": 4,
"VITAL_O_THR": 3,
"STILL_T_THR": 2,
"STILL_O_THR": 2,
"DROP_H_THR": 2,
"DROP_I_THR": 1,
}

int_mat = {
DiscordActivity.Reply: np.zeros((acc_count, acc_count)),
Expand Down
Loading