-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclarify.py
More file actions
417 lines (365 loc) · 15.5 KB
/
clarify.py
File metadata and controls
417 lines (365 loc) · 15.5 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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import altair as alt
# Set page config for wider layout
st.set_page_config(page_title="CLARIFY Scoring System", layout="wide")
# Initialize session state for storing ideas
if "ideas" not in st.session_state:
st.session_state.ideas = []
st.title("CLARIFY Scoring System for AI Ideas")
# Descriptions for tooltips with questions included
descriptions = {
"C": "Challenges & Constraints - How critical is this problem for Fleetio?\n\n"
"1: Minor inconvenience\n"
"3: Medium pain point, but not urgent\n"
"5: High-impact, costly, or a major customer complaint",
"L": "Look at the Data - Do we have the right data to make this work?\n\n"
"1: No data or requires significant collection\n"
"3: Some data available, but needs refining\n"
"5: Data is readily available and high quality",
"A": "AI Capabilities Mapping - Is AI the best way to solve this?\n\n"
"1: AI adds little value\n"
"3: AI would help, but other solutions exist\n"
"5: AI is the clear and best solution",
"R": "Reality Check - How feasible is this to build?\n\n"
"1: Requires cutting-edge AI, unclear feasibility\n"
"3: Moderate technical challenge, but achievable\n"
"5: Straightforward AI implementation with existing tech",
"I": "Integration & Implementation - How well does this fit Fleetio's platform?\n\n"
"1: Would require major new infrastructure\n"
"3: Some complexity but feasible\n"
"5: Seamless integration with existing systems",
"F": "Future-Proofing & Timeline - Can this scale and remain valuable over time?\n\n"
"1: Likely to be obsolete or require major rework soon\n"
"3: Some long-term potential, but evolving quickly\n"
"5: Strong longevity, adaptable to future needs",
"Y": "Yield & ROI Estimation - What's the potential business impact?\n\n"
"1: Marginal improvement, hard to justify\n"
"3: Moderate gains in efficiency, savings, or revenue\n"
"5: Game-changer for revenue, efficiency, or customer experience",
}
# Create a more compact scoring criteria legend
with st.expander("📊 CLARIFY Scoring Criteria", expanded=False):
# Create a table-like layout for more compact display
st.markdown(
"""
| Factor | Score 1 | Score 3 | Score 5 |
|--------|---------|---------|---------|
| **C**: Challenges & Constraints<br>*How critical is this problem?* | Minor inconvenience | Medium pain point, but not urgent | High-impact, costly, or a major customer complaint |
| **L**: Look at the Data<br>*Do we have the right data?* | No data or requires significant collection | Some data available, but needs refining | Data is readily available and high quality |
| **A**: AI Capabilities<br>*Is AI the best solution?* | AI adds little value | AI would help, but other solutions exist | AI is the clear and best solution |
| **R**: Reality Check<br>*How feasible is this to build?* | Requires cutting-edge AI, unclear feasibility | Moderate technical challenge, but achievable | Straightforward AI implementation with existing tech |
| **I**: Integration<br>*How well does this fit the platform?* | Would require major new infrastructure | Some complexity but feasible | Seamless integration with existing systems |
| **F**: Future-Proofing<br>*Can this scale and remain valuable?* | Likely to be obsolete or require major rework soon | Some long-term potential, but evolving quickly | Strong longevity, adaptable to future needs |
| **Y**: Yield & ROI<br>*What's the business impact?* | Marginal improvement, hard to justify | Moderate gains in efficiency, savings, or revenue | Game-changer for revenue, efficiency, or customer experience |
""",
unsafe_allow_html=True,
)
# Input fields for scoring an AI idea
st.subheader("Enter an AI Idea and Score It")
idea_name = st.text_input("AI Idea Name")
# Map factors to their full descriptions including questions
factor_labels = {
"C": "Challenges & Constraints - How critical is this problem?",
"L": "Look at the Data - Do we have the right data to make this work?",
"A": "AI Capabilities Mapping - Is AI the best way to solve this?",
"R": "Reality Check - How feasible is this to build?",
"I": "Integration & Implementation - How well does this fit the platform?",
"F": "Future-Proofing & Timeline - Can this scale and remain valuable over time?",
"Y": "Yield & ROI Estimation - What's the potential business impact?",
}
# Impact Factors
st.markdown("### CLARIFY Scoring")
col1, col2 = st.columns(2)
with col1:
st.markdown("**Impact Factors (C, A, F, Y)**")
challenges = st.slider("C: " + factor_labels["C"], 1, 5, 3, help=descriptions["C"])
ai_capabilities = st.slider(
"A: " + factor_labels["A"], 1, 5, 3, help=descriptions["A"]
)
future_proofing = st.slider(
"F: " + factor_labels["F"], 1, 5, 3, help=descriptions["F"]
)
yield_roi = st.slider("Y: " + factor_labels["Y"], 1, 5, 3, help=descriptions["Y"])
with col2:
st.markdown("**Effort Factors (L, R, I)**")
look_at_data = st.slider(
"L: " + factor_labels["L"], 1, 5, 3, help=descriptions["L"]
)
reality_check = st.slider(
"R: " + factor_labels["R"], 1, 5, 3, help=descriptions["R"]
)
integration = st.slider("I: " + factor_labels["I"], 1, 5, 3, help=descriptions["I"])
# Calculate scores
impact_score = challenges + ai_capabilities + future_proofing + yield_roi
effort_score = 15 - (look_at_data + reality_check + integration)
# Display the current scores
st.markdown("### Scores")
score_col1, score_col2 = st.columns(2)
with score_col1:
st.metric("Impact Score", f"{impact_score}/20")
with score_col2:
st.metric("Effort Score", f"{effort_score}/12")
# Add a side-by-side button layout
button_col1, button_col2 = st.columns(2)
with button_col1:
if st.button("Add AI Idea"):
if idea_name:
st.session_state.ideas.append(
{
"Name": idea_name,
"C": challenges,
"L": look_at_data,
"A": ai_capabilities,
"R": reality_check,
"I": integration,
"F": future_proofing,
"Y": yield_roi,
"Impact Score": impact_score,
"Effort Score": effort_score,
}
)
st.success(f"Added idea: {idea_name}")
else:
st.warning("Please enter an AI idea name.")
with button_col2:
if st.button("Reset All Ideas"):
st.session_state.ideas = []
st.success("All ideas have been cleared!")
# Display entered ideas
if st.session_state.ideas:
st.subheader("Current AI Ideas")
df = pd.DataFrame(st.session_state.ideas)
st.dataframe(df)
# Add remove individual idea functionality
st.subheader("Remove an Idea")
# Create a container for better styling
remove_container = st.container()
with remove_container:
# Use columns with better proportions for alignment
remove_col1, remove_col2 = st.columns([3, 1])
# Align items vertically by using a custom label instead
with remove_col1:
idea_to_remove = st.selectbox(
" ", # Use a space instead of a visible label
options=df["Name"].tolist(),
)
# Use vertical alignment for the button
with remove_col2:
# Add proper spacing to align with dropdown
st.markdown("<br>", unsafe_allow_html=True) # Add space with HTML
remove_button = st.button("Remove Selected Idea", key="remove_btn")
if remove_button:
# Find the index of the idea to remove
idea_index = next(
(
i
for i, idea in enumerate(st.session_state.ideas)
if idea["Name"] == idea_to_remove
),
None,
)
if idea_index is not None:
# Remove the idea from the session state
st.session_state.ideas.pop(idea_index)
st.success(f"Removed idea: {idea_to_remove}")
st.experimental_rerun()
# Plot the ideas on the effort vs. impact chart
st.subheader("AI Idea Prioritization Matrix")
fig, ax = plt.subplots(figsize=(10, 8))
# Define quadrants with even scales (0-20 for impact, 0-12 for effort)
ax.axhline(y=10, color="black", linestyle="--", alpha=0.5)
ax.axvline(x=6, color="black", linestyle="--", alpha=0.5)
# Create colored quadrants with labels
# Quick Wins (top-left)
ax.add_patch(plt.Rectangle((0, 10), 6, 10, color="purple", alpha=0.1))
# Strategic Investments (top-right)
ax.add_patch(plt.Rectangle((6, 10), 6, 10, color="green", alpha=0.1))
# Nice to Have (bottom-left)
ax.add_patch(plt.Rectangle((0, 0), 6, 10, color="blue", alpha=0.1))
# Avoid (bottom-right)
ax.add_patch(plt.Rectangle((6, 0), 6, 10, color="red", alpha=0.1))
# Labels for quadrants with clearer positioning
ax.text(
3,
18,
"QUICK WINS\n(High Impact, Low Effort)",
fontsize=12,
ha="center",
va="center",
fontweight="bold",
color="purple",
)
ax.text(
9,
18,
"STRATEGIC INVESTMENTS\n(High Impact, High Effort)",
fontsize=12,
ha="center",
va="center",
fontweight="bold",
color="green",
)
ax.text(
3,
5,
"NICE TO HAVE\n(Low Impact, Low Effort)",
fontsize=12,
ha="center",
va="center",
fontweight="bold",
color="blue",
)
ax.text(
9,
5,
"AVOID\n(Low Impact, High Effort)",
fontsize=12,
ha="center",
va="center",
fontweight="bold",
color="red",
)
# Scatter plot of AI ideas
for _, row in df.iterrows():
ax.scatter(
row["Effort Score"],
row["Impact Score"],
s=100, # Fixed size for all points
alpha=0.7,
label=row["Name"],
)
ax.text(
row["Effort Score"] + 0.3, row["Impact Score"], row["Name"], fontsize=10
)
# Set proper scales for axes
ax.set_xlim(0, 12)
ax.set_ylim(0, 20)
ax.set_xlabel("Effort (Higher = Harder)")
ax.set_ylabel("Impact (Higher = More Valuable)")
ax.set_title("AI Idea Prioritization")
st.pyplot(fig)
# Radar Chart for selected idea
if len(df) > 0:
st.subheader("CLARIFY Factor Analysis")
selected_idea = st.selectbox(
"Select an idea to view detailed CLARIFY factors:",
options=df["Name"].tolist(),
key="radar_select", # Unique key to avoid conflict with remove idea selectbox
)
if selected_idea:
idea_data = df[df["Name"] == selected_idea].iloc[0]
# Create radar chart
categories = ["C", "L", "A", "R", "I", "F", "Y"]
values = [idea_data[cat] for cat in categories]
# Close the polygon by appending the first value to the end
values_closed = values + [values[0]]
categories_closed = categories + [categories[0]]
# Calculate angle for each category
N = len(categories)
angles = [n / float(N) * 2 * np.pi for n in range(N)]
angles_closed = angles + [angles[0]]
# Create radar chart
fig, ax = plt.subplots(figsize=(8, 8), subplot_kw=dict(polar=True))
# Draw one axis per variable and add labels with questions
category_labels = [f"{cat}" for cat in categories]
plt.xticks(angles, category_labels, size=14, fontweight="bold")
# Add the questions as annotations around the radar (smaller, more compact)
for i, angle in enumerate(angles):
factor = categories[i]
question_text = factor_labels[factor].split(" - ")[1]
# Position the text at a slightly larger radius than the chart
ax.text(
angle,
6.5,
question_text,
size=7, # Smaller text
ha=(
"center"
if angle == 0 or angle == np.pi
else ("right" if 0 < angle < np.pi else "left")
),
va="center",
rotation=(
np.degrees(angle)
if 0 < angle < np.pi
else np.degrees(angle) - 180
),
)
# Draw the outline of the data
ax.plot(angles_closed, values_closed, linewidth=2, linestyle="solid")
# Fill area
ax.fill(angles_closed, values_closed, alpha=0.25)
# Set y-axis limit
ax.set_ylim(0, 5.5)
# Add circular gridlines at each score level
for score in range(1, 6):
circle = plt.Circle(
(0, 0), score, fill=False, color="gray", alpha=0.2, linestyle="-"
)
ax.add_patch(circle)
ax.text(
0,
score,
str(score),
ha="center",
va="center",
color="gray",
fontsize=8,
)
# Add title
plt.title(f"CLARIFY Factors: {selected_idea}", size=15)
# Add value annotations
for angle, value, category in zip(angles, values, categories):
ax.text(
angle,
value + 0.3,
f"{value}",
ha="center",
va="center",
size=12,
fontweight="bold",
)
st.pyplot(fig)
# Display detailed scoring for selected idea
st.subheader(f"Detailed Scores for: {selected_idea}")
# Create 7 columns for the 7 factors
factor_cols = st.columns(7)
# Map each factor to its full name
factor_full_names = {
"C": "Challenges",
"L": "Look at Data",
"A": "AI Capabilities",
"R": "Reality Check",
"I": "Integration",
"F": "Future-Proofing",
"Y": "Yield/ROI",
}
# Map scores to descriptions
score_descriptions = {
1: "Very Low",
2: "Low",
3: "Medium",
4: "High",
5: "Very High",
}
# Create color map for scores
score_colors = {
1: "red",
2: "orange",
3: "yellow",
4: "lightgreen",
5: "green",
}
# Create a detailed score card for each factor
for i, (factor, col) in enumerate(zip(categories, factor_cols)):
score = idea_data[factor]
col.markdown(f"#### {factor}")
col.markdown(f"**{factor_full_names[factor]}**")
col.markdown(
f"<h3 style='color:{score_colors[score]};'>{score}/5</h3>",
unsafe_allow_html=True,
)
col.markdown(f"*{score_descriptions[score]}*")