Configuring the notebook
Before running, you customize a few parameters directly inside the notebook cells. These are not terminal commands — you open the .ipynb file in VS Code or Jupyter, click into the relevant cell, and change the values in place.
How to edit a cell
- Open your chosen notebook (e.g.
CI-DML_AftCollabHours_PQ.ipynb). - Scroll to the cell noted below (cell numbers are indicated for each setting).
- Click into the cell and change the value.
- Don’t run the cell yet — review all parameters first, then run from the top.
A note on cell numbers Cell numbers below refer to the After-Hours and External Collaboration notebooks. The Engagement notebook has an extra survey-merge step near the top, so every cell after the setup cell is shifted by +1 (e.g. what is Cell 7 in the other notebooks is Cell 8 in the Engagement notebook). The Engagement-only section below quotes its own cell numbers directly.
1 · File paths — Cell 3 (Setup and Imports)
Update the data file path to match your CSV filename:
# Update this line to match your data file name
data_file_path = os.path.join(script_dir, '..', 'data', 'PersonQuery.csv')
# For example:
# data_file_path = os.path.join(script_dir, '..', 'data', 'MyCompany_PersonQuery_2025.csv')
In the same cell, update the output directory name:
# Replace [YOUR COMPANY] with your organization name
output_base_dir = os.path.join(script_dir, '..', 'output', 'Subgroup Analysis - [YOUR COMPANY]')
# e.g.
# output_base_dir = os.path.join(script_dir, '..', 'output', 'Subgroup Analysis - Contoso')
2 · Effect direction — Cell 3 (After-Hours & Engagement notebooks only)
In the After-Hours notebooks (CI-DML_AftCollabHours_*.ipynb) and the Engagement notebook, set which direction of effect to search for:
# Find subgroups with NEGATIVE (reductions) or POSITIVE (increases) effects
FIND_NEGATIVE_EFFECTS = True # True = reductions, False = increases
This toggle does not exist in the External Collaboration notebooks.
3 · Outcome variable & scale — Cell 5 (Engagement notebook only)
The Engagement notebook is the only scenario whose outcome is an ordinal survey metric rather than a Viva Insights metric. Because Glint survey scales vary between organizations (1–5, 1–7, 1–9, 1–10, …), you must tell the notebook both which column to use and what its scale is:
# Match OUTCOME_VAR to your Glint survey metric column name
OUTCOME_VAR = 'eSat' # e.g. 'eSat', 'eNPS', etc.
# Match the scale to your survey's response range
OUTCOME_SCALE_MIN = 1 # Minimum value on the scale
OUTCOME_SCALE_MAX = 7 # Maximum value (e.g. 5, 7, 9, or 10)
OUTCOME_VAR must match the exact column name in your Person Query export.
These parameters describe your scale — they do not transform it
OUTCOME_SCALE_MIN / OUTCOME_SCALE_MAX are used only for the ceiling/floor diagnostics and the interpretation of effect magnitudes. They do not rescale, normalise, or otherwise transform the outcome — the model is fit on the raw values in OUTCOME_VAR. Set them to match the actual response range of your survey metric. The diagnostic cell (Cell 6) prints the observed min/max and warns you if they fall outside the declared scale, so run that cell and confirm there is no mismatch before continuing.
4 · Organizational attributes — Cell 7 (Variable Definitions)
Update these lists to match the column names in your data.
SUBGROUP_VARS — attributes for subgroup / heterogeneity analysis:
SUBGROUP_VARS = [
'FunctionType', # e.g. 'Function', 'Department', 'Division'
'IsManager', # usually consistent across organizations
'LevelDesignation', # e.g. 'Level', 'Grade', 'Band'
'Organization' # update to match your data
]
These variables are used both for person-level aggregation and to identify subgroups with heterogeneous effects. Include 2–4 key attributes you want to analyze.
Network & collaboration variable lists (usually consistent, but verify)
NETWORK_VARS = [
'Internal_network_size',
'External_network_size',
'Strong_ties',
'Diverse_ties'
]
COLLABORATION_VARS = [
'Collaboration_hours',
'Available_to_focus_hours',
'Active_connected_hours',
'Uninterrupted_hours'
]
5 · Date range filter — Cell 7
Match the period covered by your data:
start_date_str = '2025-03-01' # your data's start date
end_date_str = '2025-06-30' # your data's end date
6 · Treatment & outcome — Cell 5 (usually no change)
These are typically standard, but verify they exist in your data:
- Treatment:
Total_Copilot_actions_taken - Outcome:
External_collaboration_hours,After_hours_collaboration_hours, or your chosen survey metric (e.g.eSat).
For the Engagement notebook, the outcome is specified in the configuration cell (see section 3) rather than pre-defined.
Pre-flight checklist
Before you run
- Data file is in the
data/folder data_file_pathmatches your CSV filename exactly (case-sensitive)output_base_dirhas your organization name (optional but recommended)- Every variable in
SUBGROUP_VARSexists in your dataset FIND_NEGATIVE_EFFECTSis set appropriately (after-hours & engagement only)- (Engagement only)
OUTCOME_VARmatches the survey column name - (Engagement only)
OUTCOME_SCALE_MIN/OUTCOME_SCALE_MAXmatch the survey scale