{ "cells": [ { "cell_type": "markdown", "id": "a1c6ccb7", "metadata": {}, "source": [ "# Remote Workforce Health Index - Synthetic Data Generator\n", "\n", "Notebook ini membuat **30.000 baris** data sintetis dengan pendekatan:\n", "1. **Causal-link generator** (aturan sebab-akibat)\n", "2. **SDV Gaussian Copula** untuk memperkaya variasi distribusi\n", "3. **Post-processing** agar konsisten dengan logika bisnis burnout" ] }, { "cell_type": "code", "execution_count": 1, "id": "d1f080af", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Note: you may need to restart the kernel to use updated packages.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\n", "[notice] A new release of pip is available: 25.2 -> 26.0.1\n", "[notice] To update, run: python.exe -m pip install --upgrade pip\n" ] } ], "source": [ "# Jika package belum ada, jalankan cell ini.\n", "%pip install -q pandas numpy faker sdv pyarrow" ] }, { "cell_type": "code", "execution_count": 2, "id": "87ef1394", "metadata": {}, "outputs": [], "source": [ "import random\n", "import numpy as np\n", "import pandas as pd\n", "\n", "from faker import Faker\n", "from sdv.metadata import SingleTableMetadata\n", "from sdv.single_table import GaussianCopulaSynthesizer\n", "\n", "SEED = 42\n", "N_ROWS = 30000\n", "\n", "random.seed(SEED)\n", "np.random.seed(SEED)\n", "fake = Faker('id_ID')\n", "Faker.seed(SEED)" ] }, { "cell_type": "code", "execution_count": 3, "id": "eadd8e2e", "metadata": {}, "outputs": [], "source": [ "SENIORITY_LEVELS = ['Junior', 'Mid', 'Senior']\n", "WORK_LOCATIONS = ['Home', 'Office', 'Coworking']\n", "INTERNET_LEVELS = ['Poor', 'Fair', 'Good', 'Excellent']\n", "BURNOUT_LEVELS = ['Low', 'Medium', 'High']\n", "\n", "POSITIVE_NOTES = [\n", " 'Hari produktif, pekerjaan selesai tepat waktu dan energi masih stabil.',\n", " 'Fokus bagus hari ini, meeting berjalan efisien dan tugas utama tuntas.',\n", " 'Ritme kerja nyaman, bisa selesai tanpa lembur berlebihan.'\n", "]\n", "NEUTRAL_NOTES = [\n", " 'Hari cukup padat, beberapa meeting memecah fokus tapi masih terkendali.',\n", " 'Progress ada, walau ritme kerja naik turun sepanjang hari.',\n", " 'Tugas selesai sebagian, perlu atur ulang prioritas untuk besok.'\n", "]\n", "NEGATIVE_NOTES = [\n", " 'Sangat lelah dengan meeting back-to-back, butuh istirahat.',\n", " 'Jam kerja terasa panjang dan fokus menurun di sore hari.',\n", " 'Koneksi dan tekanan deadline membuat hari ini cukup berat.'\n", "]" ] }, { "cell_type": "code", "execution_count": 4, "id": "e2770554", "metadata": {}, "outputs": [], "source": [ "def choose_work_location(seniority: str) -> str:\n", " probs = {\n", " 'Junior': [0.45, 0.35, 0.20],\n", " 'Mid': [0.50, 0.30, 0.20],\n", " 'Senior': [0.55, 0.25, 0.20],\n", " }\n", " return np.random.choice(WORK_LOCATIONS, p=probs[seniority])\n", "\n", "\n", "def choose_internet_reliability(work_location: str) -> str:\n", " probs = {\n", " 'Office': [0.02, 0.08, 0.35, 0.55],\n", " 'Home': [0.10, 0.30, 0.40, 0.20],\n", " 'Coworking': [0.04, 0.16, 0.45, 0.35],\n", " }\n", " return np.random.choice(INTERNET_LEVELS, p=probs[work_location])\n", "\n", "\n", "def generate_meeting_intensity(seniority: str) -> int:\n", " base = {'Junior': 2.0, 'Mid': 3.8, 'Senior': 5.8}[seniority]\n", " value = np.random.normal(base, 1.15)\n", " return int(np.clip(np.round(value), 0, 10))\n", "\n", "\n", "def generate_avg_working_hours(work_location: str, meeting_intensity: int) -> float:\n", " base = 7.6 + (0.45 * meeting_intensity)\n", " location_bias = {'Home': 1.0, 'Office': -0.2, 'Coworking': 0.2}[work_location]\n", " value = np.random.normal(base + location_bias, 0.75)\n", " return float(np.round(np.clip(value, 6.0, 13.0), 2))\n", "\n", "\n", "def generate_wlb(avg_hours: float, meeting_intensity: int, internet: str, work_location: str) -> int:\n", " score = 5.0\n", "\n", " if avg_hours > 9.0:\n", " score -= 1.0\n", " if avg_hours > 10.5:\n", " score -= 1.0\n", "\n", " if meeting_intensity > 5:\n", " score -= 1.0\n", " if meeting_intensity > 7:\n", " score -= 1.0\n", "\n", " if internet == 'Poor':\n", " score -= 1.0\n", " elif internet == 'Fair':\n", " score -= 0.5\n", "\n", " if work_location == 'Home' and avg_hours > 10:\n", " score -= 0.5\n", "\n", " score += np.random.choice([-0.5, 0.0, 0.5], p=[0.2, 0.6, 0.2])\n", " return int(np.clip(np.round(score), 1, 5))\n", "\n", "\n", "def generate_burnout_risk(wlb: int, avg_hours: float, meeting_intensity: int, internet: str) -> str:\n", " # Rule override untuk mencerminkan skenario ekstrem yang disebutkan\n", " if wlb <= 2 and avg_hours > 10 and np.random.rand() < 0.85:\n", " return 'High'\n", " if wlb >= 4 and 7.3 <= avg_hours <= 8.8 and meeting_intensity <= 3 and np.random.rand() < 0.85:\n", " return 'Low'\n", "\n", " risk_score = 0\n", " if wlb <= 2:\n", " risk_score += 2\n", " elif wlb == 3:\n", " risk_score += 1\n", "\n", " if avg_hours > 10:\n", " risk_score += 2\n", " elif avg_hours > 9:\n", " risk_score += 1\n", "\n", " if meeting_intensity > 6:\n", " risk_score += 1\n", "\n", " if internet == 'Poor':\n", " risk_score += 1\n", "\n", " if risk_score >= 5:\n", " probs = [0.02, 0.18, 0.80]\n", " elif risk_score >= 3:\n", " probs = [0.10, 0.45, 0.45]\n", " else:\n", " probs = [0.65, 0.30, 0.05]\n", "\n", " return np.random.choice(BURNOUT_LEVELS, p=probs)\n", "\n", "\n", "def generate_sentiment_score(wlb: int, burnout: str, internet: str) -> float:\n", " # Korelasi utama: WLB tinggi -> sentimen lebih positif\n", " base = -1.0 + ((wlb - 1) / 4.0) * 2.0\n", " noise = np.random.normal(0, 0.22)\n", "\n", " burnout_adj = {'Low': 0.12, 'Medium': -0.05, 'High': -0.22}[burnout]\n", " internet_adj = {'Poor': -0.12, 'Fair': -0.05, 'Good': 0.03, 'Excellent': 0.08}[internet]\n", "\n", " value = base + noise + burnout_adj + internet_adj\n", " return float(np.round(np.clip(value, -1.0, 1.0), 3))\n", "\n", "\n", "def generate_daily_mood_note(sentiment_score: float) -> str:\n", " if sentiment_score > 0.5:\n", " note = random.choice(POSITIVE_NOTES)\n", " elif sentiment_score < -0.5:\n", " note = random.choice(NEGATIVE_NOTES)\n", " else:\n", " note = random.choice(NEUTRAL_NOTES)\n", "\n", " # Tambahan kecil agar teks lebih beragam dan tidak terlalu templated\n", " if np.random.rand() < 0.22:\n", " note = f\"{note} Fokus tambahan: {fake.catch_phrase()}.\"\n", "\n", " return note\n", "\n", "\n", "def generate_causal_row() -> dict:\n", " seniority = np.random.choice(SENIORITY_LEVELS, p=[0.45, 0.35, 0.20])\n", " work_location = choose_work_location(seniority)\n", " internet = choose_internet_reliability(work_location)\n", "\n", " meeting_intensity = generate_meeting_intensity(seniority)\n", " avg_working_hours = generate_avg_working_hours(work_location, meeting_intensity)\n", "\n", " wlb = generate_wlb(avg_working_hours, meeting_intensity, internet, work_location)\n", " burnout = generate_burnout_risk(wlb, avg_working_hours, meeting_intensity, internet)\n", " sentiment = generate_sentiment_score(wlb, burnout, internet)\n", " mood_note = generate_daily_mood_note(sentiment)\n", "\n", " return {\n", " 'Work_Location': work_location,\n", " 'Avg_Working_Hours': avg_working_hours,\n", " 'Meeting_Intensity': meeting_intensity,\n", " 'Internet_Reliability': internet,\n", " 'Seniority_Level': seniority,\n", " 'Work_Life_Balance': wlb,\n", " 'Daily_Mood_Note': mood_note,\n", " 'Sentiment_Score': sentiment,\n", " 'Burnout_Risk': burnout,\n", " }" ] }, { "cell_type": "code", "execution_count": 5, "id": "531f6da5", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Causal data shape: (30000, 9)\n" ] }, { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "Work_Location", "rawType": "object", "type": "string" }, { "name": "Avg_Working_Hours", "rawType": "float64", "type": "float" }, { "name": "Meeting_Intensity", "rawType": "int64", "type": "integer" }, { "name": "Internet_Reliability", "rawType": "object", "type": "string" }, { "name": "Seniority_Level", "rawType": "object", "type": "string" }, { "name": "Work_Life_Balance", "rawType": "int64", "type": "integer" }, { "name": "Daily_Mood_Note", "rawType": "object", "type": "string" }, { "name": "Sentiment_Score", "rawType": "float64", "type": "float" }, { "name": "Burnout_Risk", "rawType": "object", "type": "string" } ], "ref": "3a919e97-f570-4990-b46c-3a5788630e58", "rows": [ [ "0", "Coworking", "8.49", "1", "Excellent", "Junior", "4", "Ritme kerja nyaman, bisa selesai tanpa lembur berlebihan.", "0.761", "Low" ], [ "1", "Coworking", "8.71", "3", "Excellent", "Junior", "4", "Hari produktif, pekerjaan selesai tepat waktu dan energi masih stabil.", "0.584", "Low" ], [ "2", "Home", "8.94", "2", "Good", "Junior", "5", "Hari produktif, pekerjaan selesai tepat waktu dan energi masih stabil.", "1.0", "Low" ], [ "3", "Home", "9.95", "4", "Good", "Mid", "4", "Ritme kerja nyaman, bisa selesai tanpa lembur berlebihan.", "0.688", "Medium" ], [ "4", "Office", "8.59", "2", "Fair", "Junior", "4", "Fokus bagus hari ini, meeting berjalan efisien dan tugas utama tuntas. Fokus tambahan: Sharable bifurcated algorithm.", "1.0", "Low" ] ], "shape": { "columns": 9, "rows": 5 } }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Work_LocationAvg_Working_HoursMeeting_IntensityInternet_ReliabilitySeniority_LevelWork_Life_BalanceDaily_Mood_NoteSentiment_ScoreBurnout_Risk
0Coworking8.491ExcellentJunior4Ritme kerja nyaman, bisa selesai tanpa lembur ...0.761Low
1Coworking8.713ExcellentJunior4Hari produktif, pekerjaan selesai tepat waktu ...0.584Low
2Home8.942GoodJunior5Hari produktif, pekerjaan selesai tepat waktu ...1.000Low
3Home9.954GoodMid4Ritme kerja nyaman, bisa selesai tanpa lembur ...0.688Medium
4Office8.592FairJunior4Fokus bagus hari ini, meeting berjalan efisien...1.000Low
\n", "
" ], "text/plain": [ " Work_Location Avg_Working_Hours Meeting_Intensity Internet_Reliability \\\n", "0 Coworking 8.49 1 Excellent \n", "1 Coworking 8.71 3 Excellent \n", "2 Home 8.94 2 Good \n", "3 Home 9.95 4 Good \n", "4 Office 8.59 2 Fair \n", "\n", " Seniority_Level Work_Life_Balance \\\n", "0 Junior 4 \n", "1 Junior 4 \n", "2 Junior 5 \n", "3 Mid 4 \n", "4 Junior 4 \n", "\n", " Daily_Mood_Note Sentiment_Score \\\n", "0 Ritme kerja nyaman, bisa selesai tanpa lembur ... 0.761 \n", "1 Hari produktif, pekerjaan selesai tepat waktu ... 0.584 \n", "2 Hari produktif, pekerjaan selesai tepat waktu ... 1.000 \n", "3 Ritme kerja nyaman, bisa selesai tanpa lembur ... 0.688 \n", "4 Fokus bagus hari ini, meeting berjalan efisien... 1.000 \n", "\n", " Burnout_Risk \n", "0 Low \n", "1 Low \n", "2 Low \n", "3 Medium \n", "4 Low " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 1) Generate data kausal mentah\n", "causal_rows = [generate_causal_row() for _ in range(N_ROWS)]\n", "causal_df = pd.DataFrame(causal_rows)\n", "\n", "print('Causal data shape:', causal_df.shape)\n", "causal_df.head()" ] }, { "cell_type": "code", "execution_count": 6, "id": "54c02d55", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\zakyf\\AppData\\Roaming\\Python\\Python311\\site-packages\\sdv\\single_table\\base.py:168: FutureWarning:\n", "\n", "The 'SingleTableMetadata' is deprecated. Please use the new 'Metadata' class for synthesizers.\n", "\n", "C:\\Users\\zakyf\\AppData\\Roaming\\Python\\Python311\\site-packages\\sdv\\single_table\\base.py:134: UserWarning:\n", "\n", "We strongly recommend saving the metadata using 'save_to_json' for replicability in future SDV versions.\n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "SDV refinement success: (30000, 9)\n" ] } ], "source": [ "# 2) SDV refinement untuk meningkatkan kemiripan distribusi multi-fitur\n", "# terhadap data kausal yang sudah realistis.\n", "train_cols = [\n", " 'Work_Location',\n", " 'Avg_Working_Hours',\n", " 'Meeting_Intensity',\n", " 'Internet_Reliability',\n", " 'Seniority_Level',\n", " 'Work_Life_Balance',\n", " 'Daily_Mood_Note',\n", " 'Sentiment_Score',\n", " 'Burnout_Risk',\n", "]\n", "\n", "try:\n", " metadata = SingleTableMetadata()\n", " metadata.detect_from_dataframe(causal_df[train_cols])\n", "\n", " synthesizer = GaussianCopulaSynthesizer(\n", " metadata=metadata,\n", " enforce_min_max_values=True,\n", " enforce_rounding=False\n", " )\n", " synthesizer.fit(causal_df[train_cols])\n", " refined_df = synthesizer.sample(num_rows=N_ROWS)\n", " print('SDV refinement success:', refined_df.shape)\n", "except Exception as e:\n", " print('SDV refinement skipped, fallback to causal data. Reason:', str(e))\n", " refined_df = causal_df.copy()" ] }, { "cell_type": "code", "execution_count": 7, "id": "af3fbbf3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Final data shape: (30000, 10)\n" ] }, { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "Employee_ID", "rawType": "int32", "type": "integer" }, { "name": "Work_Location", "rawType": "object", "type": "string" }, { "name": "Avg_Working_Hours", "rawType": "float64", "type": "float" }, { "name": "Meeting_Intensity", "rawType": "int32", "type": "integer" }, { "name": "Internet_Reliability", "rawType": "object", "type": "string" }, { "name": "Seniority_Level", "rawType": "object", "type": "string" }, { "name": "Work_Life_Balance", "rawType": "int32", "type": "integer" }, { "name": "Daily_Mood_Note", "rawType": "object", "type": "string" }, { "name": "Sentiment_Score", "rawType": "float64", "type": "float" }, { "name": "Burnout_Risk", "rawType": "object", "type": "string" } ], "ref": "9ff6614f-a61f-4a49-8d19-95153af3a999", "rows": [ [ "0", "1", "Home", "8.14", "2", "Fair", "Junior", "4", "Fokus bagus hari ini, meeting berjalan efisien dan tugas utama tuntas.", "0.685", "Low" ], [ "1", "2", "Office", "9.66", "4", "Good", "Mid", "2", "Hari cukup padat, beberapa meeting memecah fokus tapi masih terkendali. Fokus tambahan: Organized leadingedge info-mediaries.", "-0.463", "Medium" ], [ "2", "3", "Home", "8.21", "1", "Excellent", "Senior", "2", "Progress ada, walau ritme kerja naik turun sepanjang hari.", "-0.226", "Low" ], [ "3", "4", "Home", "9.71", "4", "Good", "Mid", "5", "Hari produktif, pekerjaan selesai tepat waktu dan energi masih stabil.", "0.897", "Low" ], [ "4", "5", "Home", "11.26", "5", "Excellent", "Mid", "4", "Progress ada, walau ritme kerja naik turun sepanjang hari. Fokus tambahan: Persistent high-level Graphical User Interface.", "0.365", "Medium" ] ], "shape": { "columns": 10, "rows": 5 } }, "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Employee_IDWork_LocationAvg_Working_HoursMeeting_IntensityInternet_ReliabilitySeniority_LevelWork_Life_BalanceDaily_Mood_NoteSentiment_ScoreBurnout_Risk
01Home8.142FairJunior4Fokus bagus hari ini, meeting berjalan efisien...0.685Low
12Office9.664GoodMid2Hari cukup padat, beberapa meeting memecah fok...-0.463Medium
23Home8.211ExcellentSenior2Progress ada, walau ritme kerja naik turun sep...-0.226Low
34Home9.714GoodMid5Hari produktif, pekerjaan selesai tepat waktu ...0.897Low
45Home11.265ExcellentMid4Progress ada, walau ritme kerja naik turun sep...0.365Medium
\n", "
" ], "text/plain": [ " Employee_ID Work_Location Avg_Working_Hours Meeting_Intensity \\\n", "0 1 Home 8.14 2 \n", "1 2 Office 9.66 4 \n", "2 3 Home 8.21 1 \n", "3 4 Home 9.71 4 \n", "4 5 Home 11.26 5 \n", "\n", " Internet_Reliability Seniority_Level Work_Life_Balance \\\n", "0 Fair Junior 4 \n", "1 Good Mid 2 \n", "2 Excellent Senior 2 \n", "3 Good Mid 5 \n", "4 Excellent Mid 4 \n", "\n", " Daily_Mood_Note Sentiment_Score \\\n", "0 Fokus bagus hari ini, meeting berjalan efisien... 0.685 \n", "1 Hari cukup padat, beberapa meeting memecah fok... -0.463 \n", "2 Progress ada, walau ritme kerja naik turun sep... -0.226 \n", "3 Hari produktif, pekerjaan selesai tepat waktu ... 0.897 \n", "4 Progress ada, walau ritme kerja naik turun sep... 0.365 \n", "\n", " Burnout_Risk \n", "0 Low \n", "1 Medium \n", "2 Low \n", "3 Low \n", "4 Medium " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# 3) Post-processing untuk jaga konsistensi aturan bisnis\n", "final_df = refined_df.copy()\n", "\n", "final_df['Work_Location'] = final_df['Work_Location'].where(\n", " final_df['Work_Location'].isin(WORK_LOCATIONS),\n", " np.random.choice(WORK_LOCATIONS, size=len(final_df), p=[0.5, 0.3, 0.2])\n", ")\n", "\n", "final_df['Seniority_Level'] = final_df['Seniority_Level'].where(\n", " final_df['Seniority_Level'].isin(SENIORITY_LEVELS),\n", " np.random.choice(SENIORITY_LEVELS, size=len(final_df), p=[0.45, 0.35, 0.2])\n", ")\n", "\n", "final_df['Internet_Reliability'] = final_df['Internet_Reliability'].where(\n", " final_df['Internet_Reliability'].isin(INTERNET_LEVELS),\n", " np.random.choice(INTERNET_LEVELS, size=len(final_df), p=[0.07, 0.22, 0.42, 0.29])\n", ")\n", "\n", "final_df['Meeting_Intensity'] = pd.to_numeric(final_df['Meeting_Intensity'], errors='coerce').fillna(3)\n", "final_df['Meeting_Intensity'] = final_df['Meeting_Intensity'].round().clip(0, 10).astype(int)\n", "\n", "final_df['Avg_Working_Hours'] = pd.to_numeric(final_df['Avg_Working_Hours'], errors='coerce').fillna(8.0)\n", "final_df['Avg_Working_Hours'] = final_df['Avg_Working_Hours'].clip(6.0, 13.0).round(2)\n", "\n", "final_df['Work_Life_Balance'] = pd.to_numeric(final_df['Work_Life_Balance'], errors='coerce').fillna(3)\n", "final_df['Work_Life_Balance'] = final_df['Work_Life_Balance'].round().clip(1, 5).astype(int)\n", "\n", "# Recompute burnout, sentiment, mood agar hubungan antar fitur tetap masuk akal\n", "final_df['Burnout_Risk'] = final_df.apply(\n", " lambda r: generate_burnout_risk(\n", " int(r['Work_Life_Balance']),\n", " float(r['Avg_Working_Hours']),\n", " int(r['Meeting_Intensity']),\n", " str(r['Internet_Reliability'])\n", " ), axis=1\n", ")\n", "\n", "final_df['Sentiment_Score'] = final_df.apply(\n", " lambda r: generate_sentiment_score(\n", " int(r['Work_Life_Balance']),\n", " str(r['Burnout_Risk']),\n", " str(r['Internet_Reliability'])\n", " ), axis=1\n", ")\n", "\n", "final_df['Daily_Mood_Note'] = final_df['Sentiment_Score'].apply(generate_daily_mood_note)\n", "\n", "# Employee_ID final, incremental\n", "final_df.insert(0, 'Employee_ID', np.arange(1, len(final_df) + 1, dtype=int))\n", "\n", "final_df = final_df[[\n", " 'Employee_ID',\n", " 'Work_Location',\n", " 'Avg_Working_Hours',\n", " 'Meeting_Intensity',\n", " 'Internet_Reliability',\n", " 'Seniority_Level',\n", " 'Work_Life_Balance',\n", " 'Daily_Mood_Note',\n", " 'Sentiment_Score',\n", " 'Burnout_Risk',\n", "]]\n", "\n", "print('Final data shape:', final_df.shape)\n", "final_df.head()" ] }, { "cell_type": "code", "execution_count": 8, "id": "664656b1", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Burnout distribution (proporsi):\n", "Burnout_Risk\n", "Low 0.519\n", "Medium 0.253\n", "High 0.228\n", "Name: proportion, dtype: float64\n", "\n", "WLB mean by burnout:\n", "Burnout_Risk\n", "High 2.46\n", "Low 4.08\n", "Medium 3.68\n", "Name: Work_Life_Balance, dtype: float64\n", "\n", "Avg working hours by burnout:\n", "Burnout_Risk\n", "High 10.60\n", "Low 9.07\n", "Medium 9.73\n", "Name: Avg_Working_Hours, dtype: float64\n", "\n", "Sentiment mean by burnout:\n", "Burnout_Risk\n", "High -0.442\n", "Low 0.635\n", "Medium 0.298\n", "Name: Sentiment_Score, dtype: float64\n" ] } ], "source": [ "# 4) Quick quality checks\n", "print('\\nBurnout distribution (proporsi):')\n", "print(final_df['Burnout_Risk'].value_counts(normalize=True).round(3))\n", "\n", "print('\\nWLB mean by burnout:')\n", "print(final_df.groupby('Burnout_Risk')['Work_Life_Balance'].mean().round(2))\n", "\n", "print('\\nAvg working hours by burnout:')\n", "print(final_df.groupby('Burnout_Risk')['Avg_Working_Hours'].mean().round(2))\n", "\n", "print('\\nSentiment mean by burnout:')\n", "print(final_df.groupby('Burnout_Risk')['Sentiment_Score'].mean().round(3))" ] }, { "cell_type": "code", "execution_count": 9, "id": "8a8b09f0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Saved: work_wellbeing_dataset.csv\n" ] } ], "source": [ "# 5) Save output\n", "csv_path = 'work_wellbeing_dataset.csv'\n", "\n", "final_df.to_csv(csv_path, index=False)\n", "\n", "print(f'Saved: {csv_path}')\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.9" } }, "nbformat": 4, "nbformat_minor": 5 }