-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_report.py
More file actions
297 lines (135 loc) · 6.96 KB
/
create_report.py
File metadata and controls
297 lines (135 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
from docx import Document
from docx.shared import Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
doc = Document()
# Title
title = doc.add_heading('Employee Sentiment Analysis', 0)
title.alignment = WD_ALIGN_PARAGRAPH.CENTER
subtitle = doc.add_paragraph('Final Report — Springer Capital AI Internship Assessment')
subtitle.alignment = WD_ALIGN_PARAGRAPH.CENTER
author = doc.add_paragraph('Lubo Bali | December 2025')
author.alignment = WD_ALIGN_PARAGRAPH.CENTER
doc.add_paragraph()
# Executive Summary
doc.add_heading('Executive Summary', level=1)
doc.add_paragraph(
'What if HR could spot a disengaged employee before they hand in their resignation? '
'This project explores that question by analyzing 2,191 employee emails using Natural Language Processing (NLP). '
'The goal: detect sentiment patterns, rank employee engagement, and flag potential flight risks automatically.'
)
doc.add_paragraph(
'The results? We identified 7 employees showing warning signs, built a predictive model with perfect accuracy, '
'and uncovered some surprising insights — like the fact that your most positive employee might also be a flight risk.'
)
# Section 1
doc.add_heading('1. The Approach', level=1)
doc.add_paragraph(
"I used TextBlob, a Python library that scores text on a scale from -1 (very negative) to +1 (very positive). "
"Each email got classified as Positive (score > 0.1), Negative (score < -0.1), or Neutral (everything in between). "
"Then I rolled these up into monthly scores per employee: each positive email adds +1, each negative subtracts -1, neutrals add 0."
)
doc.add_paragraph(
"Why this approach? It's simple, interpretable, and fast. For a first-pass analysis of employee sentiment, "
"you don't need a complex deep learning model — you need something HR can actually understand and act on."
)
# Section 2
doc.add_heading('2. What the Data Told Us', level=1)
doc.add_paragraph('Here is what I found when I dug into the numbers:')
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('The good news: ').bold = True
p.add_run('92% of emails were Neutral or Positive. This is a generally healthy workplace.')
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('The breakdown: ').bold = True
p.add_run('48% Neutral (just business), 44% Positive (friendly/constructive), 7.5% Negative (complaints/frustrations).')
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('The busiest sender: ').bold = True
p.add_run('lydia.delgado with 284 emails. But volume does not equal happiness — more on that later.')
doc.add_paragraph()
doc.add_paragraph('For detailed charts, see the visualizations folder (10 PNG files covering everything from pie charts to heatmaps).')
# Section 3
doc.add_heading('3. Who is Thriving, Who Needs Attention', level=1)
doc.add_paragraph(
'I ranked employees by their average monthly sentiment score across 24 months. '
'The score is simple: positive emails minus negative emails.'
)
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('Top 3 Performers:').bold = True
doc.add_paragraph('1. lydia.delgado — avg score 4.38 (consistently positive)')
doc.add_paragraph('2. john.arnold — avg score 4.08')
doc.add_paragraph('3. sally.beck — avg score 3.62')
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('Bottom 3 (needs attention, not necessarily bad):').bold = True
doc.add_paragraph('1. rhonda.denton — avg score 2.17')
doc.add_paragraph('2. kayne.coulter — avg score 2.58')
doc.add_paragraph('3. bobette.riner — avg score 3.21')
doc.add_paragraph()
doc.add_paragraph(
'Important note: Even the "bottom" performers have positive averages. '
'This is not about labeling people as bad — it is about identifying who might need support.'
)
# Section 4
doc.add_heading('4. Flight Risk Detection', level=1)
doc.add_paragraph(
'Here is where it gets interesting. I built a simple rule: if someone sends 4 or more negative emails '
'within any 30-day window, they get flagged as a potential flight risk. The idea is that clustered negativity '
'often signals burnout or disengagement.'
)
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('The result: 7 out of 10 employees got flagged.').bold = True
doc.add_paragraph()
doc.add_paragraph('Highest risk:')
doc.add_paragraph('• bobette.riner — 5 negative emails in one 30-day period')
doc.add_paragraph('• sally.beck — also 5 negative emails in one 30-day period')
doc.add_paragraph()
doc.add_paragraph(
'Surprise finding: lydia.delgado (our #1 positive employee!) also got flagged. '
'Even top performers have rough patches. This is why monitoring matters — you cannot assume anyone is "fine."'
)
# Section 5
doc.add_heading('5. Can We Predict Sentiment?', level=1)
doc.add_paragraph(
'I trained a Linear Regression model to predict monthly sentiment scores using 7 features: '
'message count, average length, word count, positive/negative counts, and ratios.'
)
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('Model performance: R² = 1.0 (perfect)').bold = True
doc.add_paragraph()
doc.add_paragraph(
'Why perfect? Because the monthly score is literally calculated from positive and negative counts. '
'The model just learned the formula. This is not magic — it is validation that our scoring system is mathematically consistent.'
)
doc.add_paragraph()
doc.add_paragraph(
'The real insight: other features like email length or word count had zero predictive power. '
'Busy emailers are not happier or sadder. Tone matters, volume does not.'
)
# Section 6
doc.add_heading('6. What This Means for HR', level=1)
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('Four actionable takeaways:').bold = True
doc.add_paragraph()
doc.add_paragraph('1. Monitor sentiment, not just activity. Someone sending 50 emails a week might be drowning, not thriving.')
doc.add_paragraph('2. Check in on everyone. Your star performer had the same flight risk signals as your lowest scorer.')
doc.add_paragraph('3. Adjust thresholds to your culture. 70% flagged as flight risk might mean the bar is too low for this company.')
doc.add_paragraph('4. Combine data with conversation. This tool flags who to talk to — it does not replace actually talking to them.')
doc.add_paragraph()
p = doc.add_paragraph()
p.add_run('Next steps I would recommend:').bold = True
doc.add_paragraph('• Run this analysis quarterly to catch trends early')
doc.add_paragraph('• Correlate with actual turnover data to validate the flight risk model')
doc.add_paragraph('• Consider adding more data sources (Slack, surveys) for richer insights')
# Footer
doc.add_paragraph()
doc.add_paragraph('---')
doc.add_paragraph('Built with Python, pandas, TextBlob, scikit-learn, and matplotlib.')
doc.add_paragraph('Full code and visualizations available in the GitHub repository.')
doc.save('Final Report.docx')
print('✅ Final Report.docx created (improved version)!')