yujinahn commited on
Commit
05b3183
·
verified ·
1 Parent(s): 701e44e

Upload 11 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ background_top.png filter=lfs diff=lfs merge=lfs -text
Dockerfile ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+
7
+ ENV GRADIO_SERVER_NAME=0.0.0.0
8
+ ENV GRADIO_SERVER_PORT=7860
9
+
10
+ WORKDIR /app
11
+ COPY . /app
12
+
13
+ # Python deps (from requirements.txt)
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
16
+ # Notebook execution deps
17
+ RUN pip install --no-cache-dir notebook ipykernel papermill
18
+
19
+ # Pre-install packages the notebooks use via !pip install
20
+ RUN pip install --no-cache-dir textblob faker vaderSentiment transformers
21
+
22
+ RUN python -m ipykernel install --user --name python3 --display-name "Python 3"
23
+
24
+ EXPOSE 7860
25
+
26
+ CMD ["python", "app.py"]
README.md CHANGED
@@ -1,10 +1,11 @@
1
  ---
2
- title: AS1 19 Group Project
3
- emoji: 💻
4
- colorFrom: gray
5
- colorTo: pink
6
  sdk: docker
7
  pinned: false
 
8
  ---
9
 
10
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: SE21 App Template
3
+ emoji: 📊
4
+ colorFrom: blue
5
+ colorTo: purple
6
  sdk: docker
7
  pinned: false
8
+ short_description: AI-enhanced analytics dashboard template for SE21 students
9
  ---
10
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import re
3
+ import json
4
+ import time
5
+ import traceback
6
+ from pathlib import Path
7
+ from typing import Dict, Any, List, Tuple
8
+
9
+ import pandas as pd
10
+ import gradio as gr
11
+ import papermill as pm
12
+ import plotly.graph_objects as go
13
+
14
+ # Optional LLM (HuggingFace Inference API)
15
+ try:
16
+ from huggingface_hub import InferenceClient
17
+ except Exception:
18
+ InferenceClient = None
19
+
20
+ # =========================================================
21
+ # CONFIG
22
+ # =========================================================
23
+
24
+ BASE_DIR = Path(__file__).resolve().parent
25
+
26
+ NB1 = os.environ.get("NB1", "datacreation.ipynb").strip()
27
+ NB2 = os.environ.get("NB2", "pythonanalysis.ipynb").strip()
28
+
29
+ RUNS_DIR = BASE_DIR / "runs"
30
+ ART_DIR = BASE_DIR / "artifacts"
31
+ PY_FIG_DIR = ART_DIR / "py" / "figures"
32
+ PY_TAB_DIR = ART_DIR / "py" / "tables"
33
+
34
+ PAPERMILL_TIMEOUT = int(os.environ.get("PAPERMILL_TIMEOUT", "1800"))
35
+ MAX_PREVIEW_ROWS = int(os.environ.get("MAX_FILE_PREVIEW_ROWS", "50"))
36
+ MAX_LOG_CHARS = int(os.environ.get("MAX_LOG_CHARS", "8000"))
37
+
38
+ HF_API_KEY = os.environ.get("HF_API_KEY", "").strip()
39
+ MODEL_NAME = os.environ.get("MODEL_NAME", "deepseek-ai/DeepSeek-R1").strip()
40
+ HF_PROVIDER = os.environ.get("HF_PROVIDER", "novita").strip()
41
+ N8N_WEBHOOK_URL = os.environ.get("N8N_WEBHOOK_URL", "").strip()
42
+
43
+ LLM_ENABLED = bool(HF_API_KEY) and InferenceClient is not None
44
+ llm_client = (
45
+ InferenceClient(provider=HF_PROVIDER, api_key=HF_API_KEY)
46
+ if LLM_ENABLED
47
+ else None
48
+ )
49
+
50
+ # =========================================================
51
+ # HELPERS
52
+ # =========================================================
53
+
54
+ def ensure_dirs():
55
+ for p in [RUNS_DIR, ART_DIR, PY_FIG_DIR, PY_TAB_DIR]:
56
+ p.mkdir(parents=True, exist_ok=True)
57
+
58
+ def stamp():
59
+ return time.strftime("%Y%m%d-%H%M%S")
60
+
61
+ def tail(text: str, n: int = MAX_LOG_CHARS) -> str:
62
+ return (text or "")[-n:]
63
+
64
+ def _ls(dir_path: Path, exts: Tuple[str, ...]) -> List[str]:
65
+ if not dir_path.is_dir():
66
+ return []
67
+ return sorted(p.name for p in dir_path.iterdir() if p.is_file() and p.suffix.lower() in exts)
68
+
69
+ def _read_csv(path: Path) -> pd.DataFrame:
70
+ return pd.read_csv(path, nrows=MAX_PREVIEW_ROWS)
71
+
72
+ def _read_json(path: Path):
73
+ with path.open(encoding="utf-8") as f:
74
+ return json.load(f)
75
+
76
+ def artifacts_index() -> Dict[str, Any]:
77
+ return {
78
+ "python": {
79
+ "figures": _ls(PY_FIG_DIR, (".png", ".jpg", ".jpeg")),
80
+ "tables": _ls(PY_TAB_DIR, (".csv", ".json")),
81
+ },
82
+ }
83
+
84
+ # =========================================================
85
+ # PIPELINE RUNNERS
86
+ # =========================================================
87
+
88
+ def run_notebook(nb_name: str) -> str:
89
+ ensure_dirs()
90
+ nb_in = BASE_DIR / nb_name
91
+ if not nb_in.exists():
92
+ return f"ERROR: {nb_name} not found."
93
+ nb_out = RUNS_DIR / f"run_{stamp()}_{nb_name}"
94
+ pm.execute_notebook(
95
+ input_path=str(nb_in),
96
+ output_path=str(nb_out),
97
+ cwd=str(BASE_DIR),
98
+ log_output=True,
99
+ progress_bar=False,
100
+ request_save_on_cell_execute=True,
101
+ execution_timeout=PAPERMILL_TIMEOUT,
102
+ )
103
+ return f"Executed {nb_name}"
104
+
105
+
106
+ def run_datacreation() -> str:
107
+ try:
108
+ log = run_notebook(NB1)
109
+ csvs = [f.name for f in BASE_DIR.glob("*.csv")]
110
+ return f"OK {log}\n\nCSVs now in /app:\n" + "\n".join(f" - {c}" for c in sorted(csvs))
111
+ except Exception as e:
112
+ return f"FAILED {e}\n\n{traceback.format_exc()[-2000:]}"
113
+
114
+
115
+ def run_pythonanalysis() -> str:
116
+ try:
117
+ log = run_notebook(NB2)
118
+ idx = artifacts_index()
119
+ figs = idx["python"]["figures"]
120
+ tabs = idx["python"]["tables"]
121
+ return (
122
+ f"OK {log}\n\n"
123
+ f"Figures: {', '.join(figs) or '(none)'}\n"
124
+ f"Tables: {', '.join(tabs) or '(none)'}"
125
+ )
126
+ except Exception as e:
127
+ return f"FAILED {e}\n\n{traceback.format_exc()[-2000:]}"
128
+
129
+
130
+ def run_full_pipeline() -> str:
131
+ logs = []
132
+ logs.append("=" * 50)
133
+ logs.append("STEP 1/2: Data Creation (web scraping + synthetic data)")
134
+ logs.append("=" * 50)
135
+ logs.append(run_datacreation())
136
+ logs.append("")
137
+ logs.append("=" * 50)
138
+ logs.append("STEP 2/2: Python Analysis (sentiment, ARIMA, dashboard)")
139
+ logs.append("=" * 50)
140
+ logs.append(run_pythonanalysis())
141
+ return "\n".join(logs)
142
+
143
+
144
+ # =========================================================
145
+ # GALLERY LOADERS
146
+ # =========================================================
147
+
148
+ def _load_all_figures() -> List[Tuple[str, str]]:
149
+ """Return list of (filepath, caption) for Gallery."""
150
+ items = []
151
+ for p in sorted(PY_FIG_DIR.glob("*.png")):
152
+ items.append((str(p), p.stem.replace('_', ' ').title()))
153
+ return items
154
+
155
+
156
+ def _load_table_safe(path: Path) -> pd.DataFrame:
157
+ try:
158
+ if path.suffix == ".json":
159
+ obj = _read_json(path)
160
+ if isinstance(obj, dict):
161
+ return pd.DataFrame([obj])
162
+ return pd.DataFrame(obj)
163
+ return _read_csv(path)
164
+ except Exception as e:
165
+ return pd.DataFrame([{"error": str(e)}])
166
+
167
+
168
+ def refresh_gallery():
169
+ """Called when user clicks Refresh on Gallery tab."""
170
+ figures = _load_all_figures()
171
+ idx = artifacts_index()
172
+
173
+ table_choices = list(idx["python"]["tables"])
174
+
175
+ default_df = pd.DataFrame()
176
+ if table_choices:
177
+ default_df = _load_table_safe(PY_TAB_DIR / table_choices[0])
178
+
179
+ return (
180
+ figures if figures else [],
181
+ gr.update(choices=table_choices, value=table_choices[0] if table_choices else None),
182
+ default_df,
183
+ )
184
+
185
+
186
+ def on_table_select(choice: str):
187
+ if not choice:
188
+ return pd.DataFrame([{"hint": "Select a table above."}])
189
+ path = PY_TAB_DIR / choice
190
+ if not path.exists():
191
+ return pd.DataFrame([{"error": f"File not found: {choice}"}])
192
+ return _load_table_safe(path)
193
+
194
+
195
+ # =========================================================
196
+ # KPI LOADER
197
+ # =========================================================
198
+
199
+ def load_kpis() -> Dict[str, Any]:
200
+ for candidate in [PY_TAB_DIR / "kpis.json", PY_FIG_DIR / "kpis.json"]:
201
+ if candidate.exists():
202
+ try:
203
+ return _read_json(candidate)
204
+ except Exception:
205
+ pass
206
+ return {}
207
+
208
+
209
+ # =========================================================
210
+ # AI DASHBOARD -- LLM picks what to display
211
+ # =========================================================
212
+
213
+ DASHBOARD_SYSTEM = """You are an AI dashboard assistant for a book-sales analytics app.
214
+ The user asks questions or requests about their data. You have access to pre-computed
215
+ artifacts from a Python analysis pipeline.
216
+
217
+ AVAILABLE ARTIFACTS (only reference ones that exist):
218
+ {artifacts_json}
219
+
220
+ KPI SUMMARY: {kpis_json}
221
+
222
+ YOUR JOB:
223
+ 1. Answer the user's question conversationally using the KPIs and your knowledge of the artifacts.
224
+ 2. At the END of your response, output a JSON block (fenced with ```json ... ```) that tells
225
+ the dashboard which artifact to display. The JSON must have this shape:
226
+ {{"show": "figure"|"table"|"none", "scope": "python", "filename": "..."}}
227
+
228
+ - Use "show": "figure" to display a chart image.
229
+ - Use "show": "table" to display a CSV/JSON table.
230
+ - Use "show": "none" if no artifact is relevant.
231
+
232
+ RULES:
233
+ - If the user asks about sales trends or forecasting by title, show sales_trends or arima figures.
234
+ - If the user asks about sentiment, show sentiment figure or sentiment_counts table.
235
+ - If the user asks about forecast accuracy or ARIMA, show arima figures.
236
+ - If the user asks about top sellers, show top_titles_by_units_sold.csv.
237
+ - If the user asks a general data question, pick the most relevant artifact.
238
+ - Keep your answer concise (2-4 sentences), then the JSON block.
239
+ """
240
+
241
+ JSON_BLOCK_RE = re.compile(r"```json\s*(\{.*?\})\s*```", re.DOTALL)
242
+ FALLBACK_JSON_RE = re.compile(r"\{[^{}]*\"show\"[^{}]*\}", re.DOTALL)
243
+
244
+
245
+ def _parse_display_directive(text: str) -> Dict[str, str]:
246
+ m = JSON_BLOCK_RE.search(text)
247
+ if m:
248
+ try:
249
+ return json.loads(m.group(1))
250
+ except json.JSONDecodeError:
251
+ pass
252
+ m = FALLBACK_JSON_RE.search(text)
253
+ if m:
254
+ try:
255
+ return json.loads(m.group(0))
256
+ except json.JSONDecodeError:
257
+ pass
258
+ return {"show": "none"}
259
+
260
+
261
+ def _clean_response(text: str) -> str:
262
+ """Strip the JSON directive block from the displayed response."""
263
+ return JSON_BLOCK_RE.sub("", text).strip()
264
+
265
+
266
+ def _n8n_call(msg: str) -> Tuple[str, Dict]:
267
+ """Call the student's n8n webhook and return (reply, directive)."""
268
+ import requests as req
269
+ try:
270
+ resp = req.post(N8N_WEBHOOK_URL, json={"question": msg}, timeout=20)
271
+ data = resp.json()
272
+ answer = data.get("answer", "No response from n8n workflow.")
273
+ chart = data.get("chart", "none")
274
+ if chart and chart != "none":
275
+ return answer, {"show": "figure", "chart": chart}
276
+ return answer, {"show": "none"}
277
+ except Exception as e:
278
+ return f"n8n error: {e}. Falling back to keyword matching.", None
279
+
280
+
281
+ def ai_chat(user_msg: str, history: list):
282
+ """Chat function for the AI Dashboard tab."""
283
+ if not user_msg or not user_msg.strip():
284
+ return history, "", None, None
285
+
286
+ idx = artifacts_index()
287
+ kpis = load_kpis()
288
+
289
+ # Priority: n8n webhook > HF LLM > keyword fallback
290
+ if N8N_WEBHOOK_URL:
291
+ reply, directive = _n8n_call(user_msg)
292
+ if directive is None:
293
+ reply_fb, directive = _keyword_fallback(user_msg, idx, kpis)
294
+ reply += "\n\n" + reply_fb
295
+ elif not LLM_ENABLED:
296
+ reply, directive = _keyword_fallback(user_msg, idx, kpis)
297
+ else:
298
+ system = DASHBOARD_SYSTEM.format(
299
+ artifacts_json=json.dumps(idx, indent=2),
300
+ kpis_json=json.dumps(kpis, indent=2) if kpis else "(no KPIs yet, run the pipeline first)",
301
+ )
302
+ msgs = [{"role": "system", "content": system}]
303
+ for entry in (history or [])[-6:]:
304
+ msgs.append(entry)
305
+ msgs.append({"role": "user", "content": user_msg})
306
+
307
+ try:
308
+ r = llm_client.chat_completion(
309
+ model=MODEL_NAME,
310
+ messages=msgs,
311
+ temperature=0.3,
312
+ max_tokens=600,
313
+ stream=False,
314
+ )
315
+ raw = (
316
+ r["choices"][0]["message"]["content"]
317
+ if isinstance(r, dict)
318
+ else r.choices[0].message.content
319
+ )
320
+ directive = _parse_display_directive(raw)
321
+ reply = _clean_response(raw)
322
+ except Exception as e:
323
+ reply = f"LLM error: {e}. Falling back to keyword matching."
324
+ reply_fb, directive = _keyword_fallback(user_msg, idx, kpis)
325
+ reply += "\n\n" + reply_fb
326
+
327
+ # Resolve artifacts — build interactive Plotly charts when possible
328
+ chart_out = None
329
+ tab_out = None
330
+ show = directive.get("show", "none")
331
+ fname = directive.get("filename", "")
332
+ chart_name = directive.get("chart", "")
333
+
334
+ # Interactive chart builders keyed by name
335
+ chart_builders = {
336
+ "sales": build_sales_chart,
337
+ "sentiment": build_sentiment_chart,
338
+ "top_sellers": build_top_sellers_chart,
339
+ }
340
+
341
+ if chart_name and chart_name in chart_builders:
342
+ chart_out = chart_builders[chart_name]()
343
+ elif show == "figure" and fname:
344
+ # Fallback: try to match filename to a chart builder
345
+ if "sales_trend" in fname:
346
+ chart_out = build_sales_chart()
347
+ elif "sentiment" in fname:
348
+ chart_out = build_sentiment_chart()
349
+ elif "arima" in fname or "forecast" in fname:
350
+ chart_out = build_sales_chart() # closest interactive equivalent
351
+ else:
352
+ chart_out = _empty_chart(f"No interactive chart for {fname}")
353
+
354
+ if show == "table" and fname:
355
+ fp = PY_TAB_DIR / fname
356
+ if fp.exists():
357
+ tab_out = _load_table_safe(fp)
358
+ else:
359
+ reply += f"\n\n*(Could not find table: {fname})*"
360
+
361
+ new_history = (history or []) + [
362
+ {"role": "user", "content": user_msg},
363
+ {"role": "assistant", "content": reply},
364
+ ]
365
+
366
+ return new_history, "", chart_out, tab_out
367
+
368
+
369
+ def _keyword_fallback(msg: str, idx: Dict, kpis: Dict) -> Tuple[str, Dict]:
370
+ """Simple keyword matcher when LLM is unavailable."""
371
+ msg_lower = msg.lower()
372
+
373
+ if not idx["python"]["figures"] and not idx["python"]["tables"]:
374
+ return (
375
+ "No artifacts found yet. Please run the pipeline first (Tab 1), "
376
+ "then come back here to explore the results.",
377
+ {"show": "none"},
378
+ )
379
+
380
+ kpi_text = ""
381
+ if kpis:
382
+ total = kpis.get("total_units_sold", 0)
383
+ kpi_text = (
384
+ f"Quick summary: **{kpis.get('n_titles', '?')}** book titles across "
385
+ f"**{kpis.get('n_months', '?')}** months, with **{total:,.0f}** total units sold."
386
+ )
387
+
388
+ if any(w in msg_lower for w in ["trend", "sales trend", "monthly sale"]):
389
+ return (
390
+ f"Here are the sales trends. {kpi_text}",
391
+ {"show": "figure", "chart": "sales"},
392
+ )
393
+
394
+ if any(w in msg_lower for w in ["sentiment", "review", "positive", "negative"]):
395
+ return (
396
+ f"Here is the sentiment distribution across sampled book titles. {kpi_text}",
397
+ {"show": "figure", "chart": "sentiment"},
398
+ )
399
+
400
+ if any(w in msg_lower for w in ["arima", "forecast", "predict"]):
401
+ return (
402
+ f"Here are the sales trends and forecasts. {kpi_text}",
403
+ {"show": "figure", "chart": "sales"},
404
+ )
405
+
406
+ if any(w in msg_lower for w in ["top", "best sell", "popular", "rank"]):
407
+ return (
408
+ f"Here are the top-selling titles by units sold. {kpi_text}",
409
+ {"show": "table", "scope": "python", "filename": "top_titles_by_units_sold.csv"},
410
+ )
411
+
412
+ if any(w in msg_lower for w in ["price", "pricing", "decision"]):
413
+ return (
414
+ f"Here are the pricing decisions. {kpi_text}",
415
+ {"show": "table", "scope": "python", "filename": "pricing_decisions.csv"},
416
+ )
417
+
418
+ if any(w in msg_lower for w in ["dashboard", "overview", "summary", "kpi"]):
419
+ return (
420
+ f"Dashboard overview: {kpi_text}\n\nAsk me about sales trends, sentiment, forecasts, "
421
+ "pricing, or top sellers to see specific visualizations.",
422
+ {"show": "table", "scope": "python", "filename": "df_dashboard.csv"},
423
+ )
424
+
425
+ # Default
426
+ return (
427
+ f"I can show you various analyses. {kpi_text}\n\n"
428
+ "Try asking about: **sales trends**, **sentiment**, **ARIMA forecasts**, "
429
+ "**pricing decisions**, **top sellers**, or **dashboard overview**.",
430
+ {"show": "none"},
431
+ )
432
+
433
+
434
+ # =========================================================
435
+ # KPI CARDS (BubbleBusters style)
436
+ # =========================================================
437
+
438
+ def render_kpi_cards() -> str:
439
+ kpis = load_kpis()
440
+ if not kpis:
441
+ return (
442
+ '<div style="background:rgba(255,255,255,.65);backdrop-filter:blur(16px);'
443
+ 'border-radius:20px;padding:28px;text-align:center;'
444
+ 'border:1.5px solid rgba(255,255,255,.7);'
445
+ 'box-shadow:0 8px 32px rgba(124,92,191,.08);">'
446
+ '<div style="font-size:36px;margin-bottom:10px;">📊</div>'
447
+ '<div style="color:#a48de8;font-size:14px;'
448
+ 'font-weight:800;margin-bottom:6px;">No data yet</div>'
449
+ '<div style="color:#9d8fc4;font-size:12px;">'
450
+ 'Run the pipeline to populate these cards.</div>'
451
+ '</div>'
452
+ )
453
+
454
+ def card(icon, label, value, colour):
455
+ return f"""
456
+ <div style="background:rgba(255,255,255,.72);backdrop-filter:blur(16px);
457
+ border-radius:20px;padding:18px 14px 16px;text-align:center;
458
+ border:1.5px solid rgba(255,255,255,.8);
459
+ box-shadow:0 4px 16px rgba(124,92,191,.08);
460
+ border-top:3px solid {colour};">
461
+ <div style="font-size:26px;margin-bottom:7px;line-height:1;">{icon}</div>
462
+ <div style="color:#9d8fc4;font-size:9.5px;text-transform:uppercase;
463
+ letter-spacing:1.8px;margin-bottom:7px;font-weight:800;">{label}</div>
464
+ <div style="color:#2d1f4e;font-size:16px;font-weight:800;">{value}</div>
465
+ </div>"""
466
+
467
+ kpi_config = [
468
+ ("n_titles", "📚", "Book Titles", "#a48de8"),
469
+ ("n_months", "📅", "Time Periods", "#7aa6f8"),
470
+ ("total_units_sold", "📦", "Units Sold", "#6ee7c7"),
471
+ ("total_revenue", "💰", "Revenue", "#3dcba8"),
472
+ ]
473
+
474
+ html = (
475
+ '<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));'
476
+ 'gap:12px;margin-bottom:24px;">'
477
+ )
478
+ for key, icon, label, colour in kpi_config:
479
+ val = kpis.get(key)
480
+ if val is None:
481
+ continue
482
+ if isinstance(val, (int, float)) and val > 100:
483
+ val = f"{val:,.0f}"
484
+ html += card(icon, label, str(val), colour)
485
+ # Extra KPIs not in config
486
+ known = {k for k, *_ in kpi_config}
487
+ for key, val in kpis.items():
488
+ if key not in known:
489
+ label = key.replace("_", " ").title()
490
+ if isinstance(val, (int, float)) and val > 100:
491
+ val = f"{val:,.0f}"
492
+ html += card("📈", label, str(val), "#8fa8f8")
493
+ html += "</div>"
494
+ return html
495
+
496
+
497
+ # =========================================================
498
+ # INTERACTIVE PLOTLY CHARTS (BubbleBusters style)
499
+ # =========================================================
500
+
501
+ CHART_PALETTE = ["#7c5cbf", "#2ec4a0", "#e8537a", "#e8a230", "#5e8fef",
502
+ "#c45ea8", "#3dbacc", "#a0522d", "#6aaa3a", "#d46060"]
503
+
504
+ def _styled_layout(**kwargs) -> dict:
505
+ defaults = dict(
506
+ template="plotly_white",
507
+ paper_bgcolor="rgba(255,255,255,0.95)",
508
+ plot_bgcolor="rgba(255,255,255,0.98)",
509
+ font=dict(family="system-ui, sans-serif", color="#2d1f4e", size=12),
510
+ margin=dict(l=60, r=20, t=70, b=70),
511
+ legend=dict(
512
+ orientation="h", yanchor="bottom", y=1.02, xanchor="right", x=1,
513
+ bgcolor="rgba(255,255,255,0.92)",
514
+ bordercolor="rgba(124,92,191,0.35)", borderwidth=1,
515
+ ),
516
+ title=dict(font=dict(size=15, color="#4b2d8a")),
517
+ )
518
+ defaults.update(kwargs)
519
+ return defaults
520
+
521
+
522
+ def _empty_chart(title: str) -> go.Figure:
523
+ fig = go.Figure()
524
+ fig.update_layout(
525
+ title=title, height=420, template="plotly_white",
526
+ paper_bgcolor="rgba(255,255,255,0.95)",
527
+ annotations=[dict(text="Run the pipeline to generate data",
528
+ x=0.5, y=0.5, xref="paper", yref="paper", showarrow=False,
529
+ font=dict(size=14, color="rgba(124,92,191,0.5)"))],
530
+ )
531
+ return fig
532
+
533
+
534
+ def build_sales_chart() -> go.Figure:
535
+ path = PY_TAB_DIR / "df_dashboard.csv"
536
+ if not path.exists():
537
+ return _empty_chart("Sales Trends — run the pipeline first")
538
+ df = pd.read_csv(path)
539
+ date_col = next((c for c in df.columns if "month" in c.lower() or "date" in c.lower()), None)
540
+ val_cols = [c for c in df.columns if c != date_col and df[c].dtype in ("float64", "int64")]
541
+ if not date_col or not val_cols:
542
+ return _empty_chart("Could not auto-detect columns in df_dashboard.csv")
543
+ df[date_col] = pd.to_datetime(df[date_col], errors="coerce")
544
+ fig = go.Figure()
545
+ for i, col in enumerate(val_cols):
546
+ fig.add_trace(go.Scatter(
547
+ x=df[date_col], y=df[col], name=col.replace("_", " ").title(),
548
+ mode="lines+markers", line=dict(color=CHART_PALETTE[i % len(CHART_PALETTE)], width=2),
549
+ marker=dict(size=4),
550
+ hovertemplate=f"<b>{col.replace('_',' ').title()}</b><br>%{{x|%b %Y}}: %{{y:,.0f}}<extra></extra>",
551
+ ))
552
+ fig.update_layout(**_styled_layout(height=450, hovermode="x unified",
553
+ title=dict(text="Monthly Overview")))
554
+ fig.update_xaxes(gridcolor="rgba(124,92,191,0.15)", showgrid=True)
555
+ fig.update_yaxes(gridcolor="rgba(124,92,191,0.15)", showgrid=True)
556
+ return fig
557
+
558
+
559
+ def build_sentiment_chart() -> go.Figure:
560
+ path = PY_TAB_DIR / "sentiment_counts_sampled.csv"
561
+ if not path.exists():
562
+ return _empty_chart("Sentiment Distribution — run the pipeline first")
563
+ df = pd.read_csv(path)
564
+ title_col = df.columns[0]
565
+ sent_cols = [c for c in ["negative", "neutral", "positive"] if c in df.columns]
566
+ if not sent_cols:
567
+ return _empty_chart("No sentiment columns found in CSV")
568
+ colors = {"negative": "#e8537a", "neutral": "#5e8fef", "positive": "#2ec4a0"}
569
+ fig = go.Figure()
570
+ for col in sent_cols:
571
+ fig.add_trace(go.Bar(
572
+ name=col.title(), y=df[title_col], x=df[col],
573
+ orientation="h", marker_color=colors.get(col, "#888"),
574
+ hovertemplate=f"<b>{col.title()}</b>: %{{x}}<extra></extra>",
575
+ ))
576
+ fig.update_layout(**_styled_layout(
577
+ height=max(400, len(df) * 28), barmode="stack",
578
+ title=dict(text="Sentiment Distribution by Book"),
579
+ ))
580
+ fig.update_xaxes(title="Number of Reviews")
581
+ fig.update_yaxes(autorange="reversed")
582
+ return fig
583
+
584
+
585
+ def build_top_sellers_chart() -> go.Figure:
586
+ path = PY_TAB_DIR / "top_titles_by_units_sold.csv"
587
+ if not path.exists():
588
+ return _empty_chart("Top Sellers — run the pipeline first")
589
+ df = pd.read_csv(path).head(15)
590
+ title_col = next((c for c in df.columns if "title" in c.lower()), df.columns[0])
591
+ val_col = next((c for c in df.columns if "unit" in c.lower() or "sold" in c.lower()), df.columns[-1])
592
+ fig = go.Figure(go.Bar(
593
+ y=df[title_col], x=df[val_col], orientation="h",
594
+ marker=dict(color=df[val_col], colorscale=[[0, "#c5b4f0"], [1, "#7c5cbf"]]),
595
+ hovertemplate="<b>%{y}</b><br>Units: %{x:,.0f}<extra></extra>",
596
+ ))
597
+ fig.update_layout(**_styled_layout(
598
+ height=max(400, len(df) * 30),
599
+ title=dict(text="Top Selling Titles"), showlegend=False,
600
+ ))
601
+ fig.update_yaxes(autorange="reversed")
602
+ fig.update_xaxes(title="Total Units Sold")
603
+ return fig
604
+
605
+
606
+ def refresh_dashboard():
607
+ return render_kpi_cards(), build_sales_chart(), build_sentiment_chart(), build_top_sellers_chart()
608
+
609
+
610
+ # =========================================================
611
+ # UI
612
+ # =========================================================
613
+
614
+ ensure_dirs()
615
+
616
+ def load_css() -> str:
617
+ css_path = BASE_DIR / "style.css"
618
+ return css_path.read_text(encoding="utf-8") if css_path.exists() else ""
619
+
620
+
621
+ with gr.Blocks(title="AIBDM 2026 Workshop App") as demo:
622
+
623
+ gr.Markdown(
624
+ "# SE21 App Template\n"
625
+ "*This is an app template for SE21 students*",
626
+ elem_id="escp_title",
627
+ )
628
+
629
+ # ===========================================================
630
+ # TAB 1 -- Pipeline Runner
631
+ # ===========================================================
632
+ with gr.Tab("Pipeline Runner"):
633
+ gr.Markdown()
634
+
635
+ with gr.Row():
636
+ with gr.Column(scale=1):
637
+ btn_nb1 = gr.Button("Step 1: Data Creation", variant="secondary")
638
+ with gr.Column(scale=1):
639
+ btn_nb2 = gr.Button("Step 2: Python Analysis", variant="secondary")
640
+
641
+ with gr.Row():
642
+ btn_all = gr.Button("Run Full Pipeline (Both Steps)", variant="primary")
643
+
644
+ run_log = gr.Textbox(
645
+ label="Execution Log",
646
+ lines=18,
647
+ max_lines=30,
648
+ interactive=False,
649
+ )
650
+
651
+ btn_nb1.click(run_datacreation, outputs=[run_log])
652
+ btn_nb2.click(run_pythonanalysis, outputs=[run_log])
653
+ btn_all.click(run_full_pipeline, outputs=[run_log])
654
+
655
+ # ===========================================================
656
+ # TAB 2 -- Dashboard (KPIs + Interactive Charts + Gallery)
657
+ # ===========================================================
658
+ with gr.Tab("Dashboard"):
659
+ kpi_html = gr.HTML(value=render_kpi_cards)
660
+
661
+ refresh_btn = gr.Button("Refresh Dashboard", variant="primary")
662
+
663
+ gr.Markdown("#### Interactive Charts")
664
+ chart_sales = gr.Plot(label="Monthly Overview")
665
+ chart_sentiment = gr.Plot(label="Sentiment Distribution")
666
+ chart_top = gr.Plot(label="Top Sellers")
667
+
668
+ gr.Markdown("#### Static Figures (from notebooks)")
669
+ gallery = gr.Gallery(
670
+ label="Generated Figures",
671
+ columns=2,
672
+ height=480,
673
+ object_fit="contain",
674
+ )
675
+
676
+ gr.Markdown("#### Data Tables")
677
+ table_dropdown = gr.Dropdown(
678
+ label="Select a table to view",
679
+ choices=[],
680
+ interactive=True,
681
+ )
682
+ table_display = gr.Dataframe(
683
+ label="Table Preview",
684
+ interactive=False,
685
+ )
686
+
687
+ def _on_refresh():
688
+ kpi, c1, c2, c3 = refresh_dashboard()
689
+ figs, dd, df = refresh_gallery()
690
+ return kpi, c1, c2, c3, figs, dd, df
691
+
692
+ refresh_btn.click(
693
+ _on_refresh,
694
+ outputs=[kpi_html, chart_sales, chart_sentiment, chart_top,
695
+ gallery, table_dropdown, table_display],
696
+ )
697
+ table_dropdown.change(
698
+ on_table_select,
699
+ inputs=[table_dropdown],
700
+ outputs=[table_display],
701
+ )
702
+
703
+ # ===========================================================
704
+ # TAB 3 -- AI Dashboard
705
+ # ===========================================================
706
+ with gr.Tab('"AI" Dashboard'):
707
+ _ai_status = (
708
+ "Connected to your **n8n workflow**." if N8N_WEBHOOK_URL
709
+ else "**LLM active.**" if LLM_ENABLED
710
+ else "Using **keyword matching**. Upgrade options: "
711
+ "set `N8N_WEBHOOK_URL` to connect your n8n workflow, "
712
+ "or set `HF_API_KEY` for direct LLM access."
713
+ )
714
+ gr.Markdown(
715
+ "### Ask questions, get interactive visualisations\n\n"
716
+ f"Type a question and the system will pick the right interactive chart or table. {_ai_status}"
717
+ )
718
+
719
+ with gr.Row(equal_height=True):
720
+ with gr.Column(scale=1):
721
+ chatbot = gr.Chatbot(
722
+ label="Conversation",
723
+ height=380,
724
+ )
725
+ user_input = gr.Textbox(
726
+ label="Ask about your data",
727
+ placeholder="e.g. Show me sales trends / What are the top sellers? / Sentiment analysis",
728
+ lines=1,
729
+ )
730
+ gr.Examples(
731
+ examples=[
732
+ "Show me the sales trends",
733
+ "What does the sentiment look like?",
734
+ "Which titles sell the most?",
735
+ "Show the ARIMA forecasts",
736
+ "What are the pricing decisions?",
737
+ "Give me a dashboard overview",
738
+ ],
739
+ inputs=user_input,
740
+ )
741
+
742
+ with gr.Column(scale=1):
743
+ ai_figure = gr.Plot(
744
+ label="Interactive Chart",
745
+ )
746
+ ai_table = gr.Dataframe(
747
+ label="Data Table",
748
+ interactive=False,
749
+ )
750
+
751
+ user_input.submit(
752
+ ai_chat,
753
+ inputs=[user_input, chatbot],
754
+ outputs=[chatbot, user_input, ai_figure, ai_table],
755
+ )
756
+
757
+
758
+ demo.launch(css=load_css(), allowed_paths=[str(BASE_DIR)])
background_bottom.png ADDED
background_mid.png ADDED
background_top.png ADDED

Git LFS Details

  • SHA256: 27e963d20dbb7ae88368fb527d475c85ef0de3df63d8f0d7d5e2af7403a5b365
  • Pointer size: 131 Bytes
  • Size of remote file: 726 kB
datacreation.ipynb ADDED
@@ -0,0 +1,1300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": []
7
+ },
8
+ "kernelspec": {
9
+ "name": "python3",
10
+ "display_name": "Python 3"
11
+ },
12
+ "language_info": {
13
+ "name": "python"
14
+ }
15
+ },
16
+ "cells": [
17
+ {
18
+ "cell_type": "code",
19
+ "execution_count": 5,
20
+ "metadata": {
21
+ "colab": {
22
+ "base_uri": "https://localhost:8080/"
23
+ },
24
+ "id": "XQZJSSopDet9",
25
+ "outputId": "61ea737f-4653-41ba-964f-f4c88e7a0738"
26
+ },
27
+ "outputs": [
28
+ {
29
+ "output_type": "stream",
30
+ "name": "stdout",
31
+ "text": [
32
+ "Requirement already satisfied: pandas in /usr/local/lib/python3.12/dist-packages (2.2.2)\n",
33
+ "Requirement already satisfied: numpy in /usr/local/lib/python3.12/dist-packages (2.0.2)\n",
34
+ "Requirement already satisfied: matplotlib in /usr/local/lib/python3.12/dist-packages (3.10.0)\n",
35
+ "Requirement already satisfied: scikit-learn in /usr/local/lib/python3.12/dist-packages (1.6.1)\n",
36
+ "Requirement already satisfied: statsmodels in /usr/local/lib/python3.12/dist-packages (0.14.6)\n",
37
+ "Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.12/dist-packages (from pandas) (2.9.0.post0)\n",
38
+ "Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.2)\n",
39
+ "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2026.1)\n",
40
+ "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.3.3)\n",
41
+ "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (0.12.1)\n",
42
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (4.62.1)\n",
43
+ "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.5.0)\n",
44
+ "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (26.1)\n",
45
+ "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (11.3.0)\n",
46
+ "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (3.3.2)\n",
47
+ "Requirement already satisfied: scipy>=1.6.0 in /usr/local/lib/python3.12/dist-packages (from scikit-learn) (1.16.3)\n",
48
+ "Requirement already satisfied: joblib>=1.2.0 in /usr/local/lib/python3.12/dist-packages (from scikit-learn) (1.5.3)\n",
49
+ "Requirement already satisfied: threadpoolctl>=3.1.0 in /usr/local/lib/python3.12/dist-packages (from scikit-learn) (3.6.0)\n",
50
+ "Requirement already satisfied: patsy>=0.5.6 in /usr/local/lib/python3.12/dist-packages (from statsmodels) (1.0.2)\n",
51
+ "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.12/dist-packages (from python-dateutil>=2.8.2->pandas) (1.17.0)\n"
52
+ ]
53
+ }
54
+ ],
55
+ "source": [
56
+ "!pip install pandas numpy matplotlib scikit-learn statsmodels"
57
+ ]
58
+ },
59
+ {
60
+ "cell_type": "code",
61
+ "source": [
62
+ "import random\n",
63
+ "import numpy as np\n",
64
+ "import pandas as pd\n",
65
+ "\n",
66
+ "random.seed(42)\n",
67
+ "np.random.seed(42)"
68
+ ],
69
+ "metadata": {
70
+ "id": "yzXlo3jYDi0f"
71
+ },
72
+ "execution_count": 6,
73
+ "outputs": []
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "source": [
78
+ "print(\"=\" * 50)\n",
79
+ "print(\"STEP 1/2: Data Creation (real data + synthetic enrichment)\")\n",
80
+ "print(\"=\" * 50)"
81
+ ],
82
+ "metadata": {
83
+ "colab": {
84
+ "base_uri": "https://localhost:8080/"
85
+ },
86
+ "id": "EL_CQaWsDkGw",
87
+ "outputId": "793b948a-a315-43d5-d2bc-6b8589dcb4b4"
88
+ },
89
+ "execution_count": 7,
90
+ "outputs": [
91
+ {
92
+ "output_type": "stream",
93
+ "name": "stdout",
94
+ "text": [
95
+ "==================================================\n",
96
+ "STEP 1/2: Data Creation (real data + synthetic enrichment)\n",
97
+ "==================================================\n"
98
+ ]
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "cell_type": "code",
104
+ "source": [
105
+ "jobs_df = pd.read_csv(\"CSV-JOBS.csv\")\n",
106
+ "\n",
107
+ "print(\"Shape:\", jobs_df.shape)\n",
108
+ "print(\"Columns:\")\n",
109
+ "print(jobs_df.columns.tolist())\n",
110
+ "\n",
111
+ "display(jobs_df.head())"
112
+ ],
113
+ "metadata": {
114
+ "colab": {
115
+ "base_uri": "https://localhost:8080/",
116
+ "height": 505
117
+ },
118
+ "id": "jyIW1KljDlXP",
119
+ "outputId": "ea7ebc0a-bf5f-4923-b855-2d35cbd83968"
120
+ },
121
+ "execution_count": 8,
122
+ "outputs": [
123
+ {
124
+ "output_type": "stream",
125
+ "name": "stdout",
126
+ "text": [
127
+ "Shape: (103, 9)\n",
128
+ "Columns:\n",
129
+ "['ID', 'title', 'Domain(s)', 'Grade', 'Type of contract', 'Institution(s) ', 'Location(s)', 'Deadline ', 'Link to Content']\n"
130
+ ]
131
+ },
132
+ {
133
+ "output_type": "display_data",
134
+ "data": {
135
+ "text/plain": [
136
+ " ID title \\\n",
137
+ "0 19702 Project Assistant \n",
138
+ "1 19703 Policy Officer \n",
139
+ "2 19664 Senior Military Advisor to the Executive Director \n",
140
+ "3 19665 Structures Expert \n",
141
+ "4 19666 Certification Expert - Hydromechanical and Fli... \n",
142
+ "\n",
143
+ " Domain(s) Grade Type of contract \\\n",
144
+ "0 Justice and human rights FG III Contract staff \n",
145
+ "1 Justice and human rights FG IV Contract staff \n",
146
+ "2 Transport AD 10 Temporary staff \n",
147
+ "3 Transport AD 7 Temporary staff \n",
148
+ "4 Transport AD 7 Temporary staff \n",
149
+ "\n",
150
+ " Institution(s) Location(s) \\\n",
151
+ "0 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
152
+ "1 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
153
+ "2 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
154
+ "3 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
155
+ "4 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
156
+ "\n",
157
+ " Deadline Link to Content \n",
158
+ "0 30/04/2026 - 13:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
159
+ "1 30/04/2026 - 13:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
160
+ "2 30/04/2026 - 23:59 https://eu-careers.europa.eu/en/job-opportunit... \n",
161
+ "3 30/04/2026 - 23:59 https://eu-careers.europa.eu/en/job-opportunit... \n",
162
+ "4 30/04/2026 - 23:59 https://eu-careers.europa.eu/en/job-opportunit... "
163
+ ],
164
+ "text/html": [
165
+ "\n",
166
+ " <div id=\"df-94849428-3ad1-4840-b983-058c86036565\" class=\"colab-df-container\">\n",
167
+ " <div>\n",
168
+ "<style scoped>\n",
169
+ " .dataframe tbody tr th:only-of-type {\n",
170
+ " vertical-align: middle;\n",
171
+ " }\n",
172
+ "\n",
173
+ " .dataframe tbody tr th {\n",
174
+ " vertical-align: top;\n",
175
+ " }\n",
176
+ "\n",
177
+ " .dataframe thead th {\n",
178
+ " text-align: right;\n",
179
+ " }\n",
180
+ "</style>\n",
181
+ "<table border=\"1\" class=\"dataframe\">\n",
182
+ " <thead>\n",
183
+ " <tr style=\"text-align: right;\">\n",
184
+ " <th></th>\n",
185
+ " <th>ID</th>\n",
186
+ " <th>title</th>\n",
187
+ " <th>Domain(s)</th>\n",
188
+ " <th>Grade</th>\n",
189
+ " <th>Type of contract</th>\n",
190
+ " <th>Institution(s)</th>\n",
191
+ " <th>Location(s)</th>\n",
192
+ " <th>Deadline</th>\n",
193
+ " <th>Link to Content</th>\n",
194
+ " </tr>\n",
195
+ " </thead>\n",
196
+ " <tbody>\n",
197
+ " <tr>\n",
198
+ " <th>0</th>\n",
199
+ " <td>19702</td>\n",
200
+ " <td>Project Assistant</td>\n",
201
+ " <td>Justice and human rights</td>\n",
202
+ " <td>FG III</td>\n",
203
+ " <td>Contract staff</td>\n",
204
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
205
+ " <td>Vienna (Austria)</td>\n",
206
+ " <td>30/04/2026 - 13:00</td>\n",
207
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
208
+ " </tr>\n",
209
+ " <tr>\n",
210
+ " <th>1</th>\n",
211
+ " <td>19703</td>\n",
212
+ " <td>Policy Officer</td>\n",
213
+ " <td>Justice and human rights</td>\n",
214
+ " <td>FG IV</td>\n",
215
+ " <td>Contract staff</td>\n",
216
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
217
+ " <td>Vienna (Austria)</td>\n",
218
+ " <td>30/04/2026 - 13:00</td>\n",
219
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
220
+ " </tr>\n",
221
+ " <tr>\n",
222
+ " <th>2</th>\n",
223
+ " <td>19664</td>\n",
224
+ " <td>Senior Military Advisor to the Executive Director</td>\n",
225
+ " <td>Transport</td>\n",
226
+ " <td>AD 10</td>\n",
227
+ " <td>Temporary staff</td>\n",
228
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
229
+ " <td>Cologne (Germany)</td>\n",
230
+ " <td>30/04/2026 - 23:59</td>\n",
231
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
232
+ " </tr>\n",
233
+ " <tr>\n",
234
+ " <th>3</th>\n",
235
+ " <td>19665</td>\n",
236
+ " <td>Structures Expert</td>\n",
237
+ " <td>Transport</td>\n",
238
+ " <td>AD 7</td>\n",
239
+ " <td>Temporary staff</td>\n",
240
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
241
+ " <td>Cologne (Germany)</td>\n",
242
+ " <td>30/04/2026 - 23:59</td>\n",
243
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
244
+ " </tr>\n",
245
+ " <tr>\n",
246
+ " <th>4</th>\n",
247
+ " <td>19666</td>\n",
248
+ " <td>Certification Expert - Hydromechanical and Fli...</td>\n",
249
+ " <td>Transport</td>\n",
250
+ " <td>AD 7</td>\n",
251
+ " <td>Temporary staff</td>\n",
252
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
253
+ " <td>Cologne (Germany)</td>\n",
254
+ " <td>30/04/2026 - 23:59</td>\n",
255
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
256
+ " </tr>\n",
257
+ " </tbody>\n",
258
+ "</table>\n",
259
+ "</div>\n",
260
+ " <div class=\"colab-df-buttons\">\n",
261
+ "\n",
262
+ " <div class=\"colab-df-container\">\n",
263
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-94849428-3ad1-4840-b983-058c86036565')\"\n",
264
+ " title=\"Convert this dataframe to an interactive table.\"\n",
265
+ " style=\"display:none;\">\n",
266
+ "\n",
267
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
268
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
269
+ " </svg>\n",
270
+ " </button>\n",
271
+ "\n",
272
+ " <style>\n",
273
+ " .colab-df-container {\n",
274
+ " display:flex;\n",
275
+ " gap: 12px;\n",
276
+ " }\n",
277
+ "\n",
278
+ " .colab-df-convert {\n",
279
+ " background-color: #E8F0FE;\n",
280
+ " border: none;\n",
281
+ " border-radius: 50%;\n",
282
+ " cursor: pointer;\n",
283
+ " display: none;\n",
284
+ " fill: #1967D2;\n",
285
+ " height: 32px;\n",
286
+ " padding: 0 0 0 0;\n",
287
+ " width: 32px;\n",
288
+ " }\n",
289
+ "\n",
290
+ " .colab-df-convert:hover {\n",
291
+ " background-color: #E2EBFA;\n",
292
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
293
+ " fill: #174EA6;\n",
294
+ " }\n",
295
+ "\n",
296
+ " .colab-df-buttons div {\n",
297
+ " margin-bottom: 4px;\n",
298
+ " }\n",
299
+ "\n",
300
+ " [theme=dark] .colab-df-convert {\n",
301
+ " background-color: #3B4455;\n",
302
+ " fill: #D2E3FC;\n",
303
+ " }\n",
304
+ "\n",
305
+ " [theme=dark] .colab-df-convert:hover {\n",
306
+ " background-color: #434B5C;\n",
307
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
308
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
309
+ " fill: #FFFFFF;\n",
310
+ " }\n",
311
+ " </style>\n",
312
+ "\n",
313
+ " <script>\n",
314
+ " const buttonEl =\n",
315
+ " document.querySelector('#df-94849428-3ad1-4840-b983-058c86036565 button.colab-df-convert');\n",
316
+ " buttonEl.style.display =\n",
317
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
318
+ "\n",
319
+ " async function convertToInteractive(key) {\n",
320
+ " const element = document.querySelector('#df-94849428-3ad1-4840-b983-058c86036565');\n",
321
+ " const dataTable =\n",
322
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
323
+ " [key], {});\n",
324
+ " if (!dataTable) return;\n",
325
+ "\n",
326
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
327
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
328
+ " + ' to learn more about interactive tables.';\n",
329
+ " element.innerHTML = '';\n",
330
+ " dataTable['output_type'] = 'display_data';\n",
331
+ " await google.colab.output.renderOutput(dataTable, element);\n",
332
+ " const docLink = document.createElement('div');\n",
333
+ " docLink.innerHTML = docLinkHtml;\n",
334
+ " element.appendChild(docLink);\n",
335
+ " }\n",
336
+ " </script>\n",
337
+ " </div>\n",
338
+ "\n",
339
+ "\n",
340
+ " </div>\n",
341
+ " </div>\n"
342
+ ],
343
+ "application/vnd.google.colaboratory.intrinsic+json": {
344
+ "type": "dataframe",
345
+ "summary": "{\n \"name\": \"display(jobs_df\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"ID\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 20,\n \"min\": 19664,\n \"max\": 19703,\n \"num_unique_values\": 5,\n \"samples\": [\n 19703,\n 19666,\n 19664\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"Policy Officer\",\n \"Certification Expert - Hydromechanical and Flight Control Systems\",\n \"Senior Military Advisor to the Executive Director\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Domain(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Transport\",\n \"Justice and human rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Grade\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"FG IV\",\n \"AD 7\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Type of contract\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Temporary staff\",\n \"Contract staff\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Institution(s) \",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"(EASA) European Union Aviation Safety Agency\",\n \"(FRA) European Union Agency for Fundamental Rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Location(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Cologne (Germany)\",\n \"Vienna (Austria)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Deadline \",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"30/04/2026 - 23:59\",\n \"30/04/2026 - 13:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Link to Content\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"https://eu-careers.europa.eu/en/job-opportunities/policy-officer/fra-ca-polof-fgiv-2026\",\n \"https://eu-careers.europa.eu/en/job-opportunities/certification-expert-hydromechanical-and-flight-control-systems/easa-ad-2026-997\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
346
+ }
347
+ },
348
+ "metadata": {}
349
+ }
350
+ ]
351
+ },
352
+ {
353
+ "cell_type": "code",
354
+ "source": [
355
+ "jobs_clean = jobs_df.copy()\n",
356
+ "\n",
357
+ "jobs_clean.columns = jobs_clean.columns.str.strip()\n",
358
+ "jobs_clean[\"Deadline\"] = pd.to_datetime(jobs_clean[\"Deadline\"], errors=\"coerce\")\n",
359
+ "\n",
360
+ "jobs_clean = jobs_clean.dropna(subset=[\"title\", \"Domain(s)\", \"Type of contract\", \"Deadline\"])\n",
361
+ "\n",
362
+ "print(\"Cleaned shape:\", jobs_clean.shape)\n",
363
+ "display(jobs_clean.head())"
364
+ ],
365
+ "metadata": {
366
+ "colab": {
367
+ "base_uri": "https://localhost:8080/",
368
+ "height": 505
369
+ },
370
+ "id": "UgMfW50wDm1g",
371
+ "outputId": "4b88a153-aa33-44db-87ae-28013ca4ac56"
372
+ },
373
+ "execution_count": 9,
374
+ "outputs": [
375
+ {
376
+ "output_type": "stream",
377
+ "name": "stdout",
378
+ "text": [
379
+ "Cleaned shape: (99, 9)\n"
380
+ ]
381
+ },
382
+ {
383
+ "output_type": "stream",
384
+ "name": "stderr",
385
+ "text": [
386
+ "/tmp/ipykernel_25014/2873856445.py:4: UserWarning: Parsing dates in %d/%m/%Y - %H:%M format when dayfirst=False (the default) was specified. Pass `dayfirst=True` or specify a format to silence this warning.\n",
387
+ " jobs_clean[\"Deadline\"] = pd.to_datetime(jobs_clean[\"Deadline\"], errors=\"coerce\")\n"
388
+ ]
389
+ },
390
+ {
391
+ "output_type": "display_data",
392
+ "data": {
393
+ "text/plain": [
394
+ " ID title \\\n",
395
+ "0 19702 Project Assistant \n",
396
+ "1 19703 Policy Officer \n",
397
+ "2 19664 Senior Military Advisor to the Executive Director \n",
398
+ "3 19665 Structures Expert \n",
399
+ "4 19666 Certification Expert - Hydromechanical and Fli... \n",
400
+ "\n",
401
+ " Domain(s) Grade Type of contract \\\n",
402
+ "0 Justice and human rights FG III Contract staff \n",
403
+ "1 Justice and human rights FG IV Contract staff \n",
404
+ "2 Transport AD 10 Temporary staff \n",
405
+ "3 Transport AD 7 Temporary staff \n",
406
+ "4 Transport AD 7 Temporary staff \n",
407
+ "\n",
408
+ " Institution(s) Location(s) \\\n",
409
+ "0 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
410
+ "1 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
411
+ "2 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
412
+ "3 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
413
+ "4 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
414
+ "\n",
415
+ " Deadline Link to Content \n",
416
+ "0 2026-04-30 13:00:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
417
+ "1 2026-04-30 13:00:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
418
+ "2 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
419
+ "3 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
420
+ "4 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... "
421
+ ],
422
+ "text/html": [
423
+ "\n",
424
+ " <div id=\"df-f0935762-8470-4529-94a0-87eee82320e7\" class=\"colab-df-container\">\n",
425
+ " <div>\n",
426
+ "<style scoped>\n",
427
+ " .dataframe tbody tr th:only-of-type {\n",
428
+ " vertical-align: middle;\n",
429
+ " }\n",
430
+ "\n",
431
+ " .dataframe tbody tr th {\n",
432
+ " vertical-align: top;\n",
433
+ " }\n",
434
+ "\n",
435
+ " .dataframe thead th {\n",
436
+ " text-align: right;\n",
437
+ " }\n",
438
+ "</style>\n",
439
+ "<table border=\"1\" class=\"dataframe\">\n",
440
+ " <thead>\n",
441
+ " <tr style=\"text-align: right;\">\n",
442
+ " <th></th>\n",
443
+ " <th>ID</th>\n",
444
+ " <th>title</th>\n",
445
+ " <th>Domain(s)</th>\n",
446
+ " <th>Grade</th>\n",
447
+ " <th>Type of contract</th>\n",
448
+ " <th>Institution(s)</th>\n",
449
+ " <th>Location(s)</th>\n",
450
+ " <th>Deadline</th>\n",
451
+ " <th>Link to Content</th>\n",
452
+ " </tr>\n",
453
+ " </thead>\n",
454
+ " <tbody>\n",
455
+ " <tr>\n",
456
+ " <th>0</th>\n",
457
+ " <td>19702</td>\n",
458
+ " <td>Project Assistant</td>\n",
459
+ " <td>Justice and human rights</td>\n",
460
+ " <td>FG III</td>\n",
461
+ " <td>Contract staff</td>\n",
462
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
463
+ " <td>Vienna (Austria)</td>\n",
464
+ " <td>2026-04-30 13:00:00</td>\n",
465
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
466
+ " </tr>\n",
467
+ " <tr>\n",
468
+ " <th>1</th>\n",
469
+ " <td>19703</td>\n",
470
+ " <td>Policy Officer</td>\n",
471
+ " <td>Justice and human rights</td>\n",
472
+ " <td>FG IV</td>\n",
473
+ " <td>Contract staff</td>\n",
474
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
475
+ " <td>Vienna (Austria)</td>\n",
476
+ " <td>2026-04-30 13:00:00</td>\n",
477
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
478
+ " </tr>\n",
479
+ " <tr>\n",
480
+ " <th>2</th>\n",
481
+ " <td>19664</td>\n",
482
+ " <td>Senior Military Advisor to the Executive Director</td>\n",
483
+ " <td>Transport</td>\n",
484
+ " <td>AD 10</td>\n",
485
+ " <td>Temporary staff</td>\n",
486
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
487
+ " <td>Cologne (Germany)</td>\n",
488
+ " <td>2026-04-30 23:59:00</td>\n",
489
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
490
+ " </tr>\n",
491
+ " <tr>\n",
492
+ " <th>3</th>\n",
493
+ " <td>19665</td>\n",
494
+ " <td>Structures Expert</td>\n",
495
+ " <td>Transport</td>\n",
496
+ " <td>AD 7</td>\n",
497
+ " <td>Temporary staff</td>\n",
498
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
499
+ " <td>Cologne (Germany)</td>\n",
500
+ " <td>2026-04-30 23:59:00</td>\n",
501
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
502
+ " </tr>\n",
503
+ " <tr>\n",
504
+ " <th>4</th>\n",
505
+ " <td>19666</td>\n",
506
+ " <td>Certification Expert - Hydromechanical and Fli...</td>\n",
507
+ " <td>Transport</td>\n",
508
+ " <td>AD 7</td>\n",
509
+ " <td>Temporary staff</td>\n",
510
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
511
+ " <td>Cologne (Germany)</td>\n",
512
+ " <td>2026-04-30 23:59:00</td>\n",
513
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
514
+ " </tr>\n",
515
+ " </tbody>\n",
516
+ "</table>\n",
517
+ "</div>\n",
518
+ " <div class=\"colab-df-buttons\">\n",
519
+ "\n",
520
+ " <div class=\"colab-df-container\">\n",
521
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-f0935762-8470-4529-94a0-87eee82320e7')\"\n",
522
+ " title=\"Convert this dataframe to an interactive table.\"\n",
523
+ " style=\"display:none;\">\n",
524
+ "\n",
525
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
526
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
527
+ " </svg>\n",
528
+ " </button>\n",
529
+ "\n",
530
+ " <style>\n",
531
+ " .colab-df-container {\n",
532
+ " display:flex;\n",
533
+ " gap: 12px;\n",
534
+ " }\n",
535
+ "\n",
536
+ " .colab-df-convert {\n",
537
+ " background-color: #E8F0FE;\n",
538
+ " border: none;\n",
539
+ " border-radius: 50%;\n",
540
+ " cursor: pointer;\n",
541
+ " display: none;\n",
542
+ " fill: #1967D2;\n",
543
+ " height: 32px;\n",
544
+ " padding: 0 0 0 0;\n",
545
+ " width: 32px;\n",
546
+ " }\n",
547
+ "\n",
548
+ " .colab-df-convert:hover {\n",
549
+ " background-color: #E2EBFA;\n",
550
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
551
+ " fill: #174EA6;\n",
552
+ " }\n",
553
+ "\n",
554
+ " .colab-df-buttons div {\n",
555
+ " margin-bottom: 4px;\n",
556
+ " }\n",
557
+ "\n",
558
+ " [theme=dark] .colab-df-convert {\n",
559
+ " background-color: #3B4455;\n",
560
+ " fill: #D2E3FC;\n",
561
+ " }\n",
562
+ "\n",
563
+ " [theme=dark] .colab-df-convert:hover {\n",
564
+ " background-color: #434B5C;\n",
565
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
566
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
567
+ " fill: #FFFFFF;\n",
568
+ " }\n",
569
+ " </style>\n",
570
+ "\n",
571
+ " <script>\n",
572
+ " const buttonEl =\n",
573
+ " document.querySelector('#df-f0935762-8470-4529-94a0-87eee82320e7 button.colab-df-convert');\n",
574
+ " buttonEl.style.display =\n",
575
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
576
+ "\n",
577
+ " async function convertToInteractive(key) {\n",
578
+ " const element = document.querySelector('#df-f0935762-8470-4529-94a0-87eee82320e7');\n",
579
+ " const dataTable =\n",
580
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
581
+ " [key], {});\n",
582
+ " if (!dataTable) return;\n",
583
+ "\n",
584
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
585
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
586
+ " + ' to learn more about interactive tables.';\n",
587
+ " element.innerHTML = '';\n",
588
+ " dataTable['output_type'] = 'display_data';\n",
589
+ " await google.colab.output.renderOutput(dataTable, element);\n",
590
+ " const docLink = document.createElement('div');\n",
591
+ " docLink.innerHTML = docLinkHtml;\n",
592
+ " element.appendChild(docLink);\n",
593
+ " }\n",
594
+ " </script>\n",
595
+ " </div>\n",
596
+ "\n",
597
+ "\n",
598
+ " </div>\n",
599
+ " </div>\n"
600
+ ],
601
+ "application/vnd.google.colaboratory.intrinsic+json": {
602
+ "type": "dataframe",
603
+ "summary": "{\n \"name\": \"display(jobs_clean\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"ID\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 20,\n \"min\": 19664,\n \"max\": 19703,\n \"num_unique_values\": 5,\n \"samples\": [\n 19703,\n 19666,\n 19664\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"Policy Officer\",\n \"Certification Expert - Hydromechanical and Flight Control Systems\",\n \"Senior Military Advisor to the Executive Director\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Domain(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Transport\",\n \"Justice and human rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Grade\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"FG IV\",\n \"AD 7\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Type of contract\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Temporary staff\",\n \"Contract staff\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Institution(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"(EASA) European Union Aviation Safety Agency\",\n \"(FRA) European Union Agency for Fundamental Rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Location(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Cologne (Germany)\",\n \"Vienna (Austria)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Deadline\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2026-04-30 13:00:00\",\n \"max\": \"2026-04-30 23:59:00\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"2026-04-30 23:59:00\",\n \"2026-04-30 13:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Link to Content\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"https://eu-careers.europa.eu/en/job-opportunities/policy-officer/fra-ca-polof-fgiv-2026\",\n \"https://eu-careers.europa.eu/en/job-opportunities/certification-expert-hydromechanical-and-flight-control-systems/easa-ad-2026-997\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
604
+ }
605
+ },
606
+ "metadata": {}
607
+ }
608
+ ]
609
+ },
610
+ {
611
+ "cell_type": "code",
612
+ "source": [
613
+ "print(\"Unique domains:\", jobs_clean[\"Domain(s)\"].nunique())\n",
614
+ "print(\"Unique contract types:\", jobs_clean[\"Type of contract\"].nunique())\n",
615
+ "print(\"Unique institutions:\", jobs_clean[\"Institution(s)\"].nunique())\n",
616
+ "print(\"Unique locations:\", jobs_clean[\"Location(s)\"].nunique())"
617
+ ],
618
+ "metadata": {
619
+ "colab": {
620
+ "base_uri": "https://localhost:8080/"
621
+ },
622
+ "id": "wN8LLnbqDo5H",
623
+ "outputId": "1230b9e7-4d0b-44da-bf73-61a5a39d0ab9"
624
+ },
625
+ "execution_count": 10,
626
+ "outputs": [
627
+ {
628
+ "output_type": "stream",
629
+ "name": "stdout",
630
+ "text": [
631
+ "Unique domains: 35\n",
632
+ "Unique contract types: 5\n",
633
+ "Unique institutions: 38\n",
634
+ "Unique locations: 31\n"
635
+ ]
636
+ }
637
+ ]
638
+ },
639
+ {
640
+ "cell_type": "code",
641
+ "source": [
642
+ "comments_by_demand = {\n",
643
+ " \"high\": [\n",
644
+ " \"This role appears to be in strong demand across institutions.\",\n",
645
+ " \"The labor market for this profile looks highly competitive.\",\n",
646
+ " \"This posting suggests strong employment opportunities.\",\n",
647
+ " \"Demand for this skill set appears to be growing.\",\n",
648
+ " \"This category seems to attract significant hiring activity.\"\n",
649
+ " ],\n",
650
+ " \"stable\": [\n",
651
+ " \"This role appears to have steady demand.\",\n",
652
+ " \"The market for this profile looks relatively balanced.\",\n",
653
+ " \"This posting suggests moderate but stable opportunities.\",\n",
654
+ " \"Demand appears consistent across institutions.\",\n",
655
+ " \"This category seems to have regular hiring activity.\"\n",
656
+ " ],\n",
657
+ " \"low\": [\n",
658
+ " \"This role appears to have weaker demand.\",\n",
659
+ " \"The market for this profile looks more limited.\",\n",
660
+ " \"This posting suggests fewer employment opportunities.\",\n",
661
+ " \"Demand for this skill set appears relatively low.\",\n",
662
+ " \"This category seems to have less hiring activity.\"\n",
663
+ " ]\n",
664
+ "}"
665
+ ],
666
+ "metadata": {
667
+ "id": "HHqueIqZDqVe"
668
+ },
669
+ "execution_count": 11,
670
+ "outputs": []
671
+ },
672
+ {
673
+ "cell_type": "code",
674
+ "source": [
675
+ "jobs_enriched = jobs_clean.copy()\n",
676
+ "\n",
677
+ "today = pd.Timestamp.today().normalize()\n",
678
+ "jobs_enriched[\"days_to_deadline\"] = (jobs_enriched[\"Deadline\"] - today).dt.days\n",
679
+ "\n",
680
+ "def urgency_from_days(days):\n",
681
+ " if pd.isna(days):\n",
682
+ " return random.randint(3, 6)\n",
683
+ " if days <= 7:\n",
684
+ " return random.randint(8, 10)\n",
685
+ " elif days <= 21:\n",
686
+ " return random.randint(5, 8)\n",
687
+ " else:\n",
688
+ " return random.randint(2, 6)\n",
689
+ "\n",
690
+ "jobs_enriched[\"urgency_score\"] = jobs_enriched[\"days_to_deadline\"].apply(urgency_from_days)\n",
691
+ "\n",
692
+ "def demand_from_urgency(score):\n",
693
+ " if score >= 8:\n",
694
+ " return random.randint(7, 10)\n",
695
+ " elif score >= 5:\n",
696
+ " return random.randint(4, 7)\n",
697
+ " else:\n",
698
+ " return random.randint(2, 5)\n",
699
+ "\n",
700
+ "jobs_enriched[\"job_demand_score\"] = jobs_enriched[\"urgency_score\"].apply(demand_from_urgency)\n",
701
+ "\n",
702
+ "def demand_label(score):\n",
703
+ " if score <= 3:\n",
704
+ " return \"low\"\n",
705
+ " elif score <= 6:\n",
706
+ " return \"stable\"\n",
707
+ " else:\n",
708
+ " return \"high\"\n",
709
+ "\n",
710
+ "jobs_enriched[\"demand_label\"] = jobs_enriched[\"job_demand_score\"].apply(demand_label)\n",
711
+ "\n",
712
+ "jobs_enriched[\"estimated_salary\"] = np.random.randint(35000, 95000, len(jobs_enriched))\n",
713
+ "\n",
714
+ "jobs_enriched[\"automation_risk\"] = np.random.choice(\n",
715
+ " [\"low\", \"medium\", \"high\"],\n",
716
+ " size=len(jobs_enriched),\n",
717
+ " p=[0.35, 0.45, 0.20]\n",
718
+ ")\n",
719
+ "\n",
720
+ "jobs_enriched[\"estimated_applications\"] = np.random.randint(20, 250, len(jobs_enriched))\n",
721
+ "\n",
722
+ "jobs_enriched[\"job_comment\"] = jobs_enriched[\"demand_label\"].apply(\n",
723
+ " lambda x: random.choice(comments_by_demand[x])\n",
724
+ ")\n",
725
+ "\n",
726
+ "display(jobs_enriched.head())"
727
+ ],
728
+ "metadata": {
729
+ "colab": {
730
+ "base_uri": "https://localhost:8080/",
731
+ "height": 539
732
+ },
733
+ "id": "l6PBz502Dr3a",
734
+ "outputId": "1f359396-203b-4d7a-8671-d58ccee2df1a"
735
+ },
736
+ "execution_count": 12,
737
+ "outputs": [
738
+ {
739
+ "output_type": "display_data",
740
+ "data": {
741
+ "text/plain": [
742
+ " ID title \\\n",
743
+ "0 19702 Project Assistant \n",
744
+ "1 19703 Policy Officer \n",
745
+ "2 19664 Senior Military Advisor to the Executive Director \n",
746
+ "3 19665 Structures Expert \n",
747
+ "4 19666 Certification Expert - Hydromechanical and Fli... \n",
748
+ "\n",
749
+ " Domain(s) Grade Type of contract \\\n",
750
+ "0 Justice and human rights FG III Contract staff \n",
751
+ "1 Justice and human rights FG IV Contract staff \n",
752
+ "2 Transport AD 10 Temporary staff \n",
753
+ "3 Transport AD 7 Temporary staff \n",
754
+ "4 Transport AD 7 Temporary staff \n",
755
+ "\n",
756
+ " Institution(s) Location(s) \\\n",
757
+ "0 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
758
+ "1 (FRA) European Union Agency for Fundamental Ri... Vienna (Austria) \n",
759
+ "2 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
760
+ "3 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
761
+ "4 (EASA) European Union Aviation Safety Agency Cologne (Germany) \n",
762
+ "\n",
763
+ " Deadline Link to Content \\\n",
764
+ "0 2026-04-30 13:00:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
765
+ "1 2026-04-30 13:00:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
766
+ "2 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
767
+ "3 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
768
+ "4 2026-04-30 23:59:00 https://eu-careers.europa.eu/en/job-opportunit... \n",
769
+ "\n",
770
+ " days_to_deadline urgency_score job_demand_score demand_label \\\n",
771
+ "0 1 10 9 high \n",
772
+ "1 1 8 10 high \n",
773
+ "2 1 8 10 high \n",
774
+ "3 1 10 9 high \n",
775
+ "4 1 9 8 high \n",
776
+ "\n",
777
+ " estimated_salary automation_risk estimated_applications \\\n",
778
+ "0 91422 low 87 \n",
779
+ "1 50795 low 202 \n",
780
+ "2 35860 low 222 \n",
781
+ "3 73158 medium 203 \n",
782
+ "4 89343 low 142 \n",
783
+ "\n",
784
+ " job_comment \n",
785
+ "0 Demand for this skill set appears to be growing. \n",
786
+ "1 This posting suggests strong employment opport... \n",
787
+ "2 This role appears to be in strong demand acros... \n",
788
+ "3 The labor market for this profile looks highly... \n",
789
+ "4 The labor market for this profile looks highly... "
790
+ ],
791
+ "text/html": [
792
+ "\n",
793
+ " <div id=\"df-a517b793-a4f6-427d-970a-3326feaef8c4\" class=\"colab-df-container\">\n",
794
+ " <div>\n",
795
+ "<style scoped>\n",
796
+ " .dataframe tbody tr th:only-of-type {\n",
797
+ " vertical-align: middle;\n",
798
+ " }\n",
799
+ "\n",
800
+ " .dataframe tbody tr th {\n",
801
+ " vertical-align: top;\n",
802
+ " }\n",
803
+ "\n",
804
+ " .dataframe thead th {\n",
805
+ " text-align: right;\n",
806
+ " }\n",
807
+ "</style>\n",
808
+ "<table border=\"1\" class=\"dataframe\">\n",
809
+ " <thead>\n",
810
+ " <tr style=\"text-align: right;\">\n",
811
+ " <th></th>\n",
812
+ " <th>ID</th>\n",
813
+ " <th>title</th>\n",
814
+ " <th>Domain(s)</th>\n",
815
+ " <th>Grade</th>\n",
816
+ " <th>Type of contract</th>\n",
817
+ " <th>Institution(s)</th>\n",
818
+ " <th>Location(s)</th>\n",
819
+ " <th>Deadline</th>\n",
820
+ " <th>Link to Content</th>\n",
821
+ " <th>days_to_deadline</th>\n",
822
+ " <th>urgency_score</th>\n",
823
+ " <th>job_demand_score</th>\n",
824
+ " <th>demand_label</th>\n",
825
+ " <th>estimated_salary</th>\n",
826
+ " <th>automation_risk</th>\n",
827
+ " <th>estimated_applications</th>\n",
828
+ " <th>job_comment</th>\n",
829
+ " </tr>\n",
830
+ " </thead>\n",
831
+ " <tbody>\n",
832
+ " <tr>\n",
833
+ " <th>0</th>\n",
834
+ " <td>19702</td>\n",
835
+ " <td>Project Assistant</td>\n",
836
+ " <td>Justice and human rights</td>\n",
837
+ " <td>FG III</td>\n",
838
+ " <td>Contract staff</td>\n",
839
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
840
+ " <td>Vienna (Austria)</td>\n",
841
+ " <td>2026-04-30 13:00:00</td>\n",
842
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
843
+ " <td>1</td>\n",
844
+ " <td>10</td>\n",
845
+ " <td>9</td>\n",
846
+ " <td>high</td>\n",
847
+ " <td>91422</td>\n",
848
+ " <td>low</td>\n",
849
+ " <td>87</td>\n",
850
+ " <td>Demand for this skill set appears to be growing.</td>\n",
851
+ " </tr>\n",
852
+ " <tr>\n",
853
+ " <th>1</th>\n",
854
+ " <td>19703</td>\n",
855
+ " <td>Policy Officer</td>\n",
856
+ " <td>Justice and human rights</td>\n",
857
+ " <td>FG IV</td>\n",
858
+ " <td>Contract staff</td>\n",
859
+ " <td>(FRA) European Union Agency for Fundamental Ri...</td>\n",
860
+ " <td>Vienna (Austria)</td>\n",
861
+ " <td>2026-04-30 13:00:00</td>\n",
862
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
863
+ " <td>1</td>\n",
864
+ " <td>8</td>\n",
865
+ " <td>10</td>\n",
866
+ " <td>high</td>\n",
867
+ " <td>50795</td>\n",
868
+ " <td>low</td>\n",
869
+ " <td>202</td>\n",
870
+ " <td>This posting suggests strong employment opport...</td>\n",
871
+ " </tr>\n",
872
+ " <tr>\n",
873
+ " <th>2</th>\n",
874
+ " <td>19664</td>\n",
875
+ " <td>Senior Military Advisor to the Executive Director</td>\n",
876
+ " <td>Transport</td>\n",
877
+ " <td>AD 10</td>\n",
878
+ " <td>Temporary staff</td>\n",
879
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
880
+ " <td>Cologne (Germany)</td>\n",
881
+ " <td>2026-04-30 23:59:00</td>\n",
882
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
883
+ " <td>1</td>\n",
884
+ " <td>8</td>\n",
885
+ " <td>10</td>\n",
886
+ " <td>high</td>\n",
887
+ " <td>35860</td>\n",
888
+ " <td>low</td>\n",
889
+ " <td>222</td>\n",
890
+ " <td>This role appears to be in strong demand acros...</td>\n",
891
+ " </tr>\n",
892
+ " <tr>\n",
893
+ " <th>3</th>\n",
894
+ " <td>19665</td>\n",
895
+ " <td>Structures Expert</td>\n",
896
+ " <td>Transport</td>\n",
897
+ " <td>AD 7</td>\n",
898
+ " <td>Temporary staff</td>\n",
899
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
900
+ " <td>Cologne (Germany)</td>\n",
901
+ " <td>2026-04-30 23:59:00</td>\n",
902
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
903
+ " <td>1</td>\n",
904
+ " <td>10</td>\n",
905
+ " <td>9</td>\n",
906
+ " <td>high</td>\n",
907
+ " <td>73158</td>\n",
908
+ " <td>medium</td>\n",
909
+ " <td>203</td>\n",
910
+ " <td>The labor market for this profile looks highly...</td>\n",
911
+ " </tr>\n",
912
+ " <tr>\n",
913
+ " <th>4</th>\n",
914
+ " <td>19666</td>\n",
915
+ " <td>Certification Expert - Hydromechanical and Fli...</td>\n",
916
+ " <td>Transport</td>\n",
917
+ " <td>AD 7</td>\n",
918
+ " <td>Temporary staff</td>\n",
919
+ " <td>(EASA) European Union Aviation Safety Agency</td>\n",
920
+ " <td>Cologne (Germany)</td>\n",
921
+ " <td>2026-04-30 23:59:00</td>\n",
922
+ " <td>https://eu-careers.europa.eu/en/job-opportunit...</td>\n",
923
+ " <td>1</td>\n",
924
+ " <td>9</td>\n",
925
+ " <td>8</td>\n",
926
+ " <td>high</td>\n",
927
+ " <td>89343</td>\n",
928
+ " <td>low</td>\n",
929
+ " <td>142</td>\n",
930
+ " <td>The labor market for this profile looks highly...</td>\n",
931
+ " </tr>\n",
932
+ " </tbody>\n",
933
+ "</table>\n",
934
+ "</div>\n",
935
+ " <div class=\"colab-df-buttons\">\n",
936
+ "\n",
937
+ " <div class=\"colab-df-container\">\n",
938
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-a517b793-a4f6-427d-970a-3326feaef8c4')\"\n",
939
+ " title=\"Convert this dataframe to an interactive table.\"\n",
940
+ " style=\"display:none;\">\n",
941
+ "\n",
942
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
943
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
944
+ " </svg>\n",
945
+ " </button>\n",
946
+ "\n",
947
+ " <style>\n",
948
+ " .colab-df-container {\n",
949
+ " display:flex;\n",
950
+ " gap: 12px;\n",
951
+ " }\n",
952
+ "\n",
953
+ " .colab-df-convert {\n",
954
+ " background-color: #E8F0FE;\n",
955
+ " border: none;\n",
956
+ " border-radius: 50%;\n",
957
+ " cursor: pointer;\n",
958
+ " display: none;\n",
959
+ " fill: #1967D2;\n",
960
+ " height: 32px;\n",
961
+ " padding: 0 0 0 0;\n",
962
+ " width: 32px;\n",
963
+ " }\n",
964
+ "\n",
965
+ " .colab-df-convert:hover {\n",
966
+ " background-color: #E2EBFA;\n",
967
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
968
+ " fill: #174EA6;\n",
969
+ " }\n",
970
+ "\n",
971
+ " .colab-df-buttons div {\n",
972
+ " margin-bottom: 4px;\n",
973
+ " }\n",
974
+ "\n",
975
+ " [theme=dark] .colab-df-convert {\n",
976
+ " background-color: #3B4455;\n",
977
+ " fill: #D2E3FC;\n",
978
+ " }\n",
979
+ "\n",
980
+ " [theme=dark] .colab-df-convert:hover {\n",
981
+ " background-color: #434B5C;\n",
982
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
983
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
984
+ " fill: #FFFFFF;\n",
985
+ " }\n",
986
+ " </style>\n",
987
+ "\n",
988
+ " <script>\n",
989
+ " const buttonEl =\n",
990
+ " document.querySelector('#df-a517b793-a4f6-427d-970a-3326feaef8c4 button.colab-df-convert');\n",
991
+ " buttonEl.style.display =\n",
992
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
993
+ "\n",
994
+ " async function convertToInteractive(key) {\n",
995
+ " const element = document.querySelector('#df-a517b793-a4f6-427d-970a-3326feaef8c4');\n",
996
+ " const dataTable =\n",
997
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
998
+ " [key], {});\n",
999
+ " if (!dataTable) return;\n",
1000
+ "\n",
1001
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
1002
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
1003
+ " + ' to learn more about interactive tables.';\n",
1004
+ " element.innerHTML = '';\n",
1005
+ " dataTable['output_type'] = 'display_data';\n",
1006
+ " await google.colab.output.renderOutput(dataTable, element);\n",
1007
+ " const docLink = document.createElement('div');\n",
1008
+ " docLink.innerHTML = docLinkHtml;\n",
1009
+ " element.appendChild(docLink);\n",
1010
+ " }\n",
1011
+ " </script>\n",
1012
+ " </div>\n",
1013
+ "\n",
1014
+ "\n",
1015
+ " </div>\n",
1016
+ " </div>\n"
1017
+ ],
1018
+ "application/vnd.google.colaboratory.intrinsic+json": {
1019
+ "type": "dataframe",
1020
+ "summary": "{\n \"name\": \"display(jobs_enriched\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"ID\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 20,\n \"min\": 19664,\n \"max\": 19703,\n \"num_unique_values\": 5,\n \"samples\": [\n 19703,\n 19666,\n 19664\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"Policy Officer\",\n \"Certification Expert - Hydromechanical and Flight Control Systems\",\n \"Senior Military Advisor to the Executive Director\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Domain(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Transport\",\n \"Justice and human rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Grade\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"FG IV\",\n \"AD 7\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Type of contract\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Temporary staff\",\n \"Contract staff\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Institution(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"(EASA) European Union Aviation Safety Agency\",\n \"(FRA) European Union Agency for Fundamental Rights\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Location(s)\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"Cologne (Germany)\",\n \"Vienna (Austria)\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Deadline\",\n \"properties\": {\n \"dtype\": \"date\",\n \"min\": \"2026-04-30 13:00:00\",\n \"max\": \"2026-04-30 23:59:00\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"2026-04-30 23:59:00\",\n \"2026-04-30 13:00:00\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Link to Content\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"https://eu-careers.europa.eu/en/job-opportunities/policy-officer/fra-ca-polof-fgiv-2026\",\n \"https://eu-careers.europa.eu/en/job-opportunities/certification-expert-hydromechanical-and-flight-control-systems/easa-ad-2026-997\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"days_to_deadline\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 1,\n \"max\": 1,\n \"num_unique_values\": 1,\n \"samples\": [\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"urgency_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1,\n \"min\": 8,\n \"max\": 10,\n \"num_unique_values\": 3,\n \"samples\": [\n 10\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"job_demand_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 8,\n \"max\": 10,\n \"num_unique_values\": 3,\n \"samples\": [\n 9\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"demand_label\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"high\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"estimated_salary\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 24288,\n \"min\": 35860,\n \"max\": 91422,\n \"num_unique_values\": 5,\n \"samples\": [\n 50795\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"automation_risk\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 2,\n \"samples\": [\n \"medium\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"estimated_applications\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 55,\n \"min\": 87,\n \"max\": 222,\n \"num_unique_values\": 5,\n \"samples\": [\n 202\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"job_comment\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 4,\n \"samples\": [\n \"This posting suggests strong employment opportunities.\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
1021
+ }
1022
+ },
1023
+ "metadata": {}
1024
+ }
1025
+ ]
1026
+ },
1027
+ {
1028
+ "cell_type": "code",
1029
+ "source": [
1030
+ "jobs_enriched.to_csv(\"jobs_enriched.csv\", index=False)\n",
1031
+ "print(\"Saved: jobs_enriched.csv\")"
1032
+ ],
1033
+ "metadata": {
1034
+ "colab": {
1035
+ "base_uri": "https://localhost:8080/"
1036
+ },
1037
+ "id": "s00SIZBsDtd-",
1038
+ "outputId": "e5dbe4a5-e76a-48b2-ac18-866a964dfe3d"
1039
+ },
1040
+ "execution_count": 13,
1041
+ "outputs": [
1042
+ {
1043
+ "output_type": "stream",
1044
+ "name": "stdout",
1045
+ "text": [
1046
+ "Saved: jobs_enriched.csv\n"
1047
+ ]
1048
+ }
1049
+ ]
1050
+ },
1051
+ {
1052
+ "cell_type": "code",
1053
+ "source": [
1054
+ "jobs_enriched[\"deadline_month\"] = jobs_enriched[\"Deadline\"].dt.to_period(\"M\").astype(str)\n",
1055
+ "\n",
1056
+ "monthly_openings = (\n",
1057
+ " jobs_enriched\n",
1058
+ " .groupby([\"deadline_month\", \"Domain(s)\"], as_index=False)\n",
1059
+ " .agg(\n",
1060
+ " postings=(\"title\", \"count\"),\n",
1061
+ " avg_salary=(\"estimated_salary\", \"mean\"),\n",
1062
+ " avg_demand_score=(\"job_demand_score\", \"mean\"),\n",
1063
+ " avg_applications=(\"estimated_applications\", \"mean\")\n",
1064
+ " )\n",
1065
+ ")\n",
1066
+ "\n",
1067
+ "display(monthly_openings.head())\n",
1068
+ "print(\"Shape:\", monthly_openings.shape)"
1069
+ ],
1070
+ "metadata": {
1071
+ "colab": {
1072
+ "base_uri": "https://localhost:8080/",
1073
+ "height": 241
1074
+ },
1075
+ "id": "3NtBDh8ODvLW",
1076
+ "outputId": "f2fab0c5-a09f-4276-a1c7-f171375ac23b"
1077
+ },
1078
+ "execution_count": 14,
1079
+ "outputs": [
1080
+ {
1081
+ "output_type": "display_data",
1082
+ "data": {
1083
+ "text/plain": [
1084
+ " deadline_month Domain(s) postings avg_salary \\\n",
1085
+ "0 2026-04 Data protection 1 79732.000000 \n",
1086
+ "1 2026-04 Economics, Finance and Statistics 1 46284.000000 \n",
1087
+ "2 2026-04 Human Resources 1 89886.000000 \n",
1088
+ "3 2026-04 Justice and human rights 2 71108.500000 \n",
1089
+ "4 2026-04 Transport 3 66120.333333 \n",
1090
+ "\n",
1091
+ " avg_demand_score avg_applications \n",
1092
+ "0 8.0 164.0 \n",
1093
+ "1 10.0 57.0 \n",
1094
+ "2 7.0 43.0 \n",
1095
+ "3 9.5 144.5 \n",
1096
+ "4 9.0 189.0 "
1097
+ ],
1098
+ "text/html": [
1099
+ "\n",
1100
+ " <div id=\"df-8cae9ab8-ac0a-4995-90c7-0321e6dabc74\" class=\"colab-df-container\">\n",
1101
+ " <div>\n",
1102
+ "<style scoped>\n",
1103
+ " .dataframe tbody tr th:only-of-type {\n",
1104
+ " vertical-align: middle;\n",
1105
+ " }\n",
1106
+ "\n",
1107
+ " .dataframe tbody tr th {\n",
1108
+ " vertical-align: top;\n",
1109
+ " }\n",
1110
+ "\n",
1111
+ " .dataframe thead th {\n",
1112
+ " text-align: right;\n",
1113
+ " }\n",
1114
+ "</style>\n",
1115
+ "<table border=\"1\" class=\"dataframe\">\n",
1116
+ " <thead>\n",
1117
+ " <tr style=\"text-align: right;\">\n",
1118
+ " <th></th>\n",
1119
+ " <th>deadline_month</th>\n",
1120
+ " <th>Domain(s)</th>\n",
1121
+ " <th>postings</th>\n",
1122
+ " <th>avg_salary</th>\n",
1123
+ " <th>avg_demand_score</th>\n",
1124
+ " <th>avg_applications</th>\n",
1125
+ " </tr>\n",
1126
+ " </thead>\n",
1127
+ " <tbody>\n",
1128
+ " <tr>\n",
1129
+ " <th>0</th>\n",
1130
+ " <td>2026-04</td>\n",
1131
+ " <td>Data protection</td>\n",
1132
+ " <td>1</td>\n",
1133
+ " <td>79732.000000</td>\n",
1134
+ " <td>8.0</td>\n",
1135
+ " <td>164.0</td>\n",
1136
+ " </tr>\n",
1137
+ " <tr>\n",
1138
+ " <th>1</th>\n",
1139
+ " <td>2026-04</td>\n",
1140
+ " <td>Economics, Finance and Statistics</td>\n",
1141
+ " <td>1</td>\n",
1142
+ " <td>46284.000000</td>\n",
1143
+ " <td>10.0</td>\n",
1144
+ " <td>57.0</td>\n",
1145
+ " </tr>\n",
1146
+ " <tr>\n",
1147
+ " <th>2</th>\n",
1148
+ " <td>2026-04</td>\n",
1149
+ " <td>Human Resources</td>\n",
1150
+ " <td>1</td>\n",
1151
+ " <td>89886.000000</td>\n",
1152
+ " <td>7.0</td>\n",
1153
+ " <td>43.0</td>\n",
1154
+ " </tr>\n",
1155
+ " <tr>\n",
1156
+ " <th>3</th>\n",
1157
+ " <td>2026-04</td>\n",
1158
+ " <td>Justice and human rights</td>\n",
1159
+ " <td>2</td>\n",
1160
+ " <td>71108.500000</td>\n",
1161
+ " <td>9.5</td>\n",
1162
+ " <td>144.5</td>\n",
1163
+ " </tr>\n",
1164
+ " <tr>\n",
1165
+ " <th>4</th>\n",
1166
+ " <td>2026-04</td>\n",
1167
+ " <td>Transport</td>\n",
1168
+ " <td>3</td>\n",
1169
+ " <td>66120.333333</td>\n",
1170
+ " <td>9.0</td>\n",
1171
+ " <td>189.0</td>\n",
1172
+ " </tr>\n",
1173
+ " </tbody>\n",
1174
+ "</table>\n",
1175
+ "</div>\n",
1176
+ " <div class=\"colab-df-buttons\">\n",
1177
+ "\n",
1178
+ " <div class=\"colab-df-container\">\n",
1179
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-8cae9ab8-ac0a-4995-90c7-0321e6dabc74')\"\n",
1180
+ " title=\"Convert this dataframe to an interactive table.\"\n",
1181
+ " style=\"display:none;\">\n",
1182
+ "\n",
1183
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
1184
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
1185
+ " </svg>\n",
1186
+ " </button>\n",
1187
+ "\n",
1188
+ " <style>\n",
1189
+ " .colab-df-container {\n",
1190
+ " display:flex;\n",
1191
+ " gap: 12px;\n",
1192
+ " }\n",
1193
+ "\n",
1194
+ " .colab-df-convert {\n",
1195
+ " background-color: #E8F0FE;\n",
1196
+ " border: none;\n",
1197
+ " border-radius: 50%;\n",
1198
+ " cursor: pointer;\n",
1199
+ " display: none;\n",
1200
+ " fill: #1967D2;\n",
1201
+ " height: 32px;\n",
1202
+ " padding: 0 0 0 0;\n",
1203
+ " width: 32px;\n",
1204
+ " }\n",
1205
+ "\n",
1206
+ " .colab-df-convert:hover {\n",
1207
+ " background-color: #E2EBFA;\n",
1208
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
1209
+ " fill: #174EA6;\n",
1210
+ " }\n",
1211
+ "\n",
1212
+ " .colab-df-buttons div {\n",
1213
+ " margin-bottom: 4px;\n",
1214
+ " }\n",
1215
+ "\n",
1216
+ " [theme=dark] .colab-df-convert {\n",
1217
+ " background-color: #3B4455;\n",
1218
+ " fill: #D2E3FC;\n",
1219
+ " }\n",
1220
+ "\n",
1221
+ " [theme=dark] .colab-df-convert:hover {\n",
1222
+ " background-color: #434B5C;\n",
1223
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
1224
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
1225
+ " fill: #FFFFFF;\n",
1226
+ " }\n",
1227
+ " </style>\n",
1228
+ "\n",
1229
+ " <script>\n",
1230
+ " const buttonEl =\n",
1231
+ " document.querySelector('#df-8cae9ab8-ac0a-4995-90c7-0321e6dabc74 button.colab-df-convert');\n",
1232
+ " buttonEl.style.display =\n",
1233
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
1234
+ "\n",
1235
+ " async function convertToInteractive(key) {\n",
1236
+ " const element = document.querySelector('#df-8cae9ab8-ac0a-4995-90c7-0321e6dabc74');\n",
1237
+ " const dataTable =\n",
1238
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
1239
+ " [key], {});\n",
1240
+ " if (!dataTable) return;\n",
1241
+ "\n",
1242
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
1243
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
1244
+ " + ' to learn more about interactive tables.';\n",
1245
+ " element.innerHTML = '';\n",
1246
+ " dataTable['output_type'] = 'display_data';\n",
1247
+ " await google.colab.output.renderOutput(dataTable, element);\n",
1248
+ " const docLink = document.createElement('div');\n",
1249
+ " docLink.innerHTML = docLinkHtml;\n",
1250
+ " element.appendChild(docLink);\n",
1251
+ " }\n",
1252
+ " </script>\n",
1253
+ " </div>\n",
1254
+ "\n",
1255
+ "\n",
1256
+ " </div>\n",
1257
+ " </div>\n"
1258
+ ],
1259
+ "application/vnd.google.colaboratory.intrinsic+json": {
1260
+ "type": "dataframe",
1261
+ "summary": "{\n \"name\": \"print(\\\"Shape:\\\", monthly_openings\",\n \"rows\": 5,\n \"fields\": [\n {\n \"column\": \"deadline_month\",\n \"properties\": {\n \"dtype\": \"object\",\n \"num_unique_values\": 1,\n \"samples\": [\n \"2026-04\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"Domain(s)\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"Economics, Finance and Statistics\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"postings\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 1,\n \"max\": 3,\n \"num_unique_values\": 3,\n \"samples\": [\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"avg_salary\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 16331.975065972749,\n \"min\": 46284.0,\n \"max\": 89886.0,\n \"num_unique_values\": 5,\n \"samples\": [\n 46284.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"avg_demand_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 1.2041594578792296,\n \"min\": 7.0,\n \"max\": 10.0,\n \"num_unique_values\": 5,\n \"samples\": [\n 10.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"avg_applications\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 65.56294685262401,\n \"min\": 43.0,\n \"max\": 189.0,\n \"num_unique_values\": 5,\n \"samples\": [\n 57.0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
1262
+ }
1263
+ },
1264
+ "metadata": {}
1265
+ },
1266
+ {
1267
+ "output_type": "stream",
1268
+ "name": "stdout",
1269
+ "text": [
1270
+ "Shape: (51, 6)\n"
1271
+ ]
1272
+ }
1273
+ ]
1274
+ },
1275
+ {
1276
+ "cell_type": "code",
1277
+ "source": [
1278
+ "monthly_openings.to_csv(\"jobs_monthly_openings.csv\", index=False)\n",
1279
+ "print(\"Saved: jobs_monthly_openings.csv\")"
1280
+ ],
1281
+ "metadata": {
1282
+ "colab": {
1283
+ "base_uri": "https://localhost:8080/"
1284
+ },
1285
+ "id": "_WpGUgWSDxDr",
1286
+ "outputId": "3214fc49-8b8f-4810-eed9-6befe196b7df"
1287
+ },
1288
+ "execution_count": 15,
1289
+ "outputs": [
1290
+ {
1291
+ "output_type": "stream",
1292
+ "name": "stdout",
1293
+ "text": [
1294
+ "Saved: jobs_monthly_openings.csv\n"
1295
+ ]
1296
+ }
1297
+ ]
1298
+ }
1299
+ ]
1300
+ }
gitattributes ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ background_top.png filter=lfs diff=lfs merge=lfs -text
pythonanalysis.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ gradio==6.0.0
2
+ pandas>=2.0.0
3
+ numpy>=1.24.0
4
+ matplotlib>=3.7.0
5
+ seaborn>=0.13.0
6
+ statsmodels>=0.14.0
7
+ scikit-learn>=1.3.0
8
+ papermill>=2.5.0
9
+ nbformat>=5.9.0
10
+ pillow>=10.0.0
11
+ requests>=2.31.0
12
+ beautifulsoup4>=4.12.0
13
+ vaderSentiment>=3.3.2
14
+ huggingface_hub>=0.20.0
15
+ textblob>=0.18.0
16
+ faker>=20.0.0
17
+ plotly>=5.18.0
style.css ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* --- Target the Gradio app wrapper for backgrounds --- */
2
+ gradio-app,
3
+ .gradio-app,
4
+ .main,
5
+ #app,
6
+ [data-testid="app"] {
7
+ background-color: rgb(40,9,109) !important;
8
+ background-image:
9
+ url('https://huggingface.co/spaces/atascioglu/SE21AppTemplate/resolve/main/background_top.png'),
10
+ url('https://huggingface.co/spaces/atascioglu/SE21AppTemplate/resolve/main/background_mid.png'),
11
+ url('https://huggingface.co/spaces/atascioglu/SE21AppTemplate/resolve/main/background_bottom.png') !important;
12
+ background-position:
13
+ top center,
14
+ 0 913px,
15
+ bottom center !important;
16
+ background-repeat:
17
+ no-repeat,
18
+ repeat-y,
19
+ no-repeat !important;
20
+ background-size:
21
+ 100% auto,
22
+ 100% auto,
23
+ 100% auto !important;
24
+ min-height: 100vh !important;
25
+ }
26
+
27
+ /* --- Fallback on html/body --- */
28
+ html, body {
29
+ background-color: rgb(40,9,109) !important;
30
+ margin: 0 !important;
31
+ padding: 0 !important;
32
+ min-height: 100vh !important;
33
+ }
34
+
35
+ /* Bottom image is now part of the main background layers (positioned at bottom center) */
36
+
37
+ /* --- Main container --- */
38
+ .gradio-container {
39
+ max-width: 1400px !important;
40
+ width: 94vw !important;
41
+ margin: 0 auto !important;
42
+ padding-top: 220px !important;
43
+ padding-bottom: 150px !important;
44
+ background: transparent !important;
45
+ }
46
+
47
+ /* --- Title in ESCP gold --- */
48
+ #escp_title h1 {
49
+ color: rgb(242,198,55) !important;
50
+ font-size: 3rem !important;
51
+ font-weight: 800 !important;
52
+ text-align: center !important;
53
+ margin: 0 0 12px 0 !important;
54
+ }
55
+
56
+ /* --- Subtitle --- */
57
+ #escp_title p, #escp_title em {
58
+ color: rgba(255,255,255,0.85) !important;
59
+ text-align: center !important;
60
+ }
61
+
62
+ /* --- Tab bar background --- */
63
+ .tabs > .tab-nav,
64
+ .tab-nav,
65
+ div[role="tablist"],
66
+ .svelte-tabs > .tab-nav {
67
+ background: rgba(40,9,109,0.6) !important;
68
+ border-radius: 10px 10px 0 0 !important;
69
+ padding: 4px !important;
70
+ }
71
+
72
+ /* --- ALL tab buttons: force white text --- */
73
+ .tabs > .tab-nav button,
74
+ .tab-nav button,
75
+ div[role="tablist"] button,
76
+ button[role="tab"],
77
+ .svelte-tabs button,
78
+ .tab-nav > button,
79
+ .tabs button {
80
+ color: #ffffff !important;
81
+ font-weight: 600 !important;
82
+ border: none !important;
83
+ background: transparent !important;
84
+ padding: 10px 20px !important;
85
+ border-radius: 8px 8px 0 0 !important;
86
+ opacity: 1 !important;
87
+ }
88
+
89
+ /* --- Selected tab: ESCP gold --- */
90
+ .tabs > .tab-nav button.selected,
91
+ .tab-nav button.selected,
92
+ button[role="tab"][aria-selected="true"],
93
+ button[role="tab"].selected,
94
+ div[role="tablist"] button[aria-selected="true"],
95
+ .svelte-tabs button.selected {
96
+ color: rgb(242,198,55) !important;
97
+ background: rgba(255,255,255,0.12) !important;
98
+ }
99
+
100
+ /* --- Unselected tabs: ensure visibility --- */
101
+ .tabs > .tab-nav button:not(.selected),
102
+ .tab-nav button:not(.selected),
103
+ button[role="tab"][aria-selected="false"],
104
+ button[role="tab"]:not(.selected),
105
+ div[role="tablist"] button:not([aria-selected="true"]) {
106
+ color: #ffffff !important;
107
+ opacity: 1 !important;
108
+ }
109
+
110
+ /* --- White card panels --- */
111
+ .gradio-container .gr-block,
112
+ .gradio-container .gr-box,
113
+ .gradio-container .gr-panel,
114
+ .gradio-container .gr-group {
115
+ background: #ffffff !important;
116
+ border-radius: 10px !important;
117
+ }
118
+
119
+ /* --- Tab content area --- */
120
+ .tabitem {
121
+ background: rgba(255,255,255,0.95) !important;
122
+ border-radius: 0 0 10px 10px !important;
123
+ padding: 16px !important;
124
+ }
125
+
126
+ /* --- Inputs --- */
127
+ .gradio-container input,
128
+ .gradio-container textarea,
129
+ .gradio-container select {
130
+ background: #ffffff !important;
131
+ border: 1px solid #d1d5db !important;
132
+ border-radius: 8px !important;
133
+ }
134
+
135
+ /* --- Buttons: ESCP purple primary --- */
136
+ .gradio-container button:not([role="tab"]) {
137
+ font-weight: 600 !important;
138
+ padding: 10px 16px !important;
139
+ border-radius: 10px !important;
140
+ }
141
+
142
+ button.primary {
143
+ background-color: rgb(40,9,109) !important;
144
+ color: #ffffff !important;
145
+ border: none !important;
146
+ }
147
+
148
+ button.primary:hover {
149
+ background-color: rgb(60,20,140) !important;
150
+ }
151
+
152
+ button.secondary {
153
+ background-color: #ffffff !important;
154
+ color: rgb(40,9,109) !important;
155
+ border: 2px solid rgb(40,9,109) !important;
156
+ }
157
+
158
+ button.secondary:hover {
159
+ background-color: rgb(240,238,250) !important;
160
+ }
161
+
162
+ /* --- Dataframes --- */
163
+ [data-testid="dataframe"] {
164
+ background-color: #ffffff !important;
165
+ border-radius: 10px !important;
166
+ }
167
+
168
+ table {
169
+ font-size: 0.85rem !important;
170
+ }
171
+
172
+ /* --- Chatbot (AI Dashboard tab) --- */
173
+ .gr-chatbot {
174
+ min-height: 380px !important;
175
+ background-color: #ffffff !important;
176
+ border-radius: 12px !important;
177
+ }
178
+
179
+ .gr-chatbot .message.user {
180
+ background-color: rgb(232,225,250) !important;
181
+ border-radius: 12px !important;
182
+ }
183
+
184
+ .gr-chatbot .message.bot {
185
+ background-color: #f3f4f6 !important;
186
+ border-radius: 12px !important;
187
+ }
188
+
189
+ /* --- Gallery --- */
190
+ .gallery {
191
+ background: #ffffff !important;
192
+ border-radius: 10px !important;
193
+ }
194
+
195
+ /* --- Log textbox --- */
196
+ textarea {
197
+ font-family: monospace !important;
198
+ font-size: 0.8rem !important;
199
+ }
200
+
201
+ /* --- Markdown headings inside tabs --- */
202
+ .tabitem h3 {
203
+ color: rgb(40,9,109) !important;
204
+ font-weight: 700 !important;
205
+ }
206
+
207
+ .tabitem h4 {
208
+ color: #374151 !important;
209
+ }
210
+
211
+ /* --- Examples row (AI Dashboard) --- */
212
+ .examples-row button {
213
+ background: rgb(240,238,250) !important;
214
+ color: rgb(40,9,109) !important;
215
+ border: 1px solid rgb(40,9,109) !important;
216
+ border-radius: 8px !important;
217
+ font-size: 0.85rem !important;
218
+ }
219
+
220
+ .examples-row button:hover {
221
+ background: rgb(232,225,250) !important;
222
+ }
223
+
224
+ /* --- Header / footer: transparent over banner --- */
225
+ header, header *,
226
+ footer, footer * {
227
+ background: transparent !important;
228
+ box-shadow: none !important;
229
+ }
230
+
231
+ footer a, footer button,
232
+ header a, header button {
233
+ background: transparent !important;
234
+ border: none !important;
235
+ box-shadow: none !important;
236
+ }
237
+
238
+ #footer, #footer *,
239
+ [class*="footer"], [class*="footer"] *,
240
+ [class*="chip"], [class*="pill"], [class*="chip"] *, [class*="pill"] * {
241
+ background: transparent !important;
242
+ border: none !important;
243
+ box-shadow: none !important;
244
+ }
245
+
246
+ [data-testid*="api"], [data-testid*="settings"],
247
+ [id*="api"], [id*="settings"],
248
+ [class*="api"], [class*="settings"],
249
+ [class*="bottom"], [class*="toolbar"], [class*="controls"] {
250
+ background: transparent !important;
251
+ box-shadow: none !important;
252
+ }
253
+
254
+ [data-testid*="api"] *, [data-testid*="settings"] *,
255
+ [id*="api"] *, [id*="settings"] *,
256
+ [class*="api"] *, [class*="settings"] * {
257
+ background: transparent !important;
258
+ box-shadow: none !important;
259
+ }
260
+
261
+ section footer {
262
+ background: transparent !important;
263
+ }
264
+
265
+ section footer button,
266
+ section footer a {
267
+ background: transparent !important;
268
+ background-color: transparent !important;
269
+ border: none !important;
270
+ box-shadow: none !important;
271
+ color: white !important;
272
+ }
273
+
274
+ section footer button:hover,
275
+ section footer button:focus,
276
+ section footer a:hover,
277
+ section footer a:focus {
278
+ background: transparent !important;
279
+ background-color: transparent !important;
280
+ box-shadow: none !important;
281
+ }
282
+
283
+ section footer button,
284
+ section footer button * {
285
+ background: transparent !important;
286
+ background-color: transparent !important;
287
+ background-image: none !important;
288
+ box-shadow: none !important;
289
+ filter: none !important;
290
+ }
291
+
292
+ section footer button::before,
293
+ section footer button::after {
294
+ background: transparent !important;
295
+ background-color: transparent !important;
296
+ background-image: none !important;
297
+ box-shadow: none !important;
298
+ filter: none !important;
299
+ }
300
+
301
+ section footer a,
302
+ section footer a * {
303
+ background: transparent !important;
304
+ background-color: transparent !important;
305
+ box-shadow: none !important;
306
+ }
307
+
308
+ .gradio-container footer button,
309
+ .gradio-container footer button *,
310
+ .gradio-container .footer button,
311
+ .gradio-container .footer button * {
312
+ background: transparent !important;
313
+ background-color: transparent !important;
314
+ background-image: none !important;
315
+ box-shadow: none !important;
316
+ }
317
+
318
+ .gradio-container footer button::before,
319
+ .gradio-container footer button::after,
320
+ .gradio-container .footer button::before,
321
+ .gradio-container .footer button::after {
322
+ background: transparent !important;
323
+ background-color: transparent !important;
324
+ background-image: none !important;
325
+ box-shadow: none !important;
326
+ }