Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +37 -47
templates/index.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>Dynamic Analytics & Operational Simulator</title>
|
| 7 |
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 8 |
<style>
|
| 9 |
:root {
|
|
@@ -22,12 +22,10 @@
|
|
| 22 |
body { background-color: var(--bg-main); color: var(--text-primary); padding: 30px 20px; min-height: 100vh; }
|
| 23 |
.container { max-width: 1200px; margin: 0 auto; }
|
| 24 |
|
| 25 |
-
/* Glossy Header */
|
| 26 |
header { margin-bottom: 30px; text-align: center; }
|
| 27 |
header h1 { font-size: 2.2rem; font-weight: 800; background: linear-gradient(135deg, #60a5fa, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 28 |
header p { color: var(--text-secondary); margin-top: 6px; font-size: 0.95rem; }
|
| 29 |
|
| 30 |
-
/* Upload Toolbar */
|
| 31 |
.upload-bar {
|
| 32 |
background: var(--card-bg);
|
| 33 |
border: 1px solid var(--card-border);
|
|
@@ -50,30 +48,26 @@
|
|
| 50 |
}
|
| 51 |
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5); }
|
| 52 |
|
| 53 |
-
|
| 54 |
-
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 35px; }
|
| 55 |
.metric-card {
|
| 56 |
background: var(--card-bg);
|
| 57 |
border: 1px solid var(--card-border);
|
| 58 |
backdrop-filter: blur(12px);
|
| 59 |
border-radius: 18px;
|
| 60 |
-
padding:
|
| 61 |
position: relative;
|
| 62 |
overflow: hidden;
|
| 63 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
| 64 |
}
|
| 65 |
-
.metric-card::before {
|
| 66 |
-
content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
|
| 67 |
-
}
|
| 68 |
.card-c1::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
|
| 69 |
.card-c2::before { background: linear-gradient(90deg, #10b981, #34d399); }
|
| 70 |
.card-c3::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
|
| 71 |
.card-c4::before { background: linear-gradient(90deg, #a855f7, #c084fc); }
|
| 72 |
|
| 73 |
-
.metric-title { font-size: 0.
|
| 74 |
-
.metric-value { font-size:
|
| 75 |
|
| 76 |
-
/* Navigation Tabs */
|
| 77 |
.tabs-nav { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 1px solid var(--card-border); padding-bottom: 10px; }
|
| 78 |
.tab-btn {
|
| 79 |
background: transparent; color: var(--text-secondary); border: none; padding: 12px 24px;
|
|
@@ -81,15 +75,11 @@
|
|
| 81 |
}
|
| 82 |
.tab-btn.active-btn { background: var(--accent-blue); color: white; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4); }
|
| 83 |
|
| 84 |
-
/* Tab Content Panes */
|
| 85 |
.tab-pane { display: none; }
|
| 86 |
.tab-pane.active-pane { display: block; }
|
| 87 |
|
| 88 |
-
/* Features Display Grid */
|
| 89 |
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
|
| 90 |
-
.feature-box {
|
| 91 |
-
background: var(--card-bg); border: 1px solid var(--card-border); padding: 25px; border-radius: 18px;
|
| 92 |
-
}
|
| 93 |
.feature-box h3 { font-size: 1.1rem; margin-bottom: 15px; color: var(--text-primary); }
|
| 94 |
.feature-box ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
|
| 95 |
.feature-box li {
|
|
@@ -97,17 +87,13 @@
|
|
| 97 |
padding: 6px 14px; border-radius: 50px; font-size: 0.85rem; color: #cbd5e1;
|
| 98 |
}
|
| 99 |
|
| 100 |
-
|
| 101 |
-
.
|
| 102 |
-
.slider-card {
|
| 103 |
-
background: var(--card-bg); border: 1px solid var(--card-border); padding: 18px; border-radius: 14px;
|
| 104 |
-
}
|
| 105 |
.slider-card label { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
|
| 106 |
input[type="range"] {
|
| 107 |
width: 100%; height: 6px; background: #334155; border-radius: 5px; outline: none; accent-color: var(--accent-blue);
|
| 108 |
}
|
| 109 |
|
| 110 |
-
/* Simulator CTA Bar */
|
| 111 |
.simulator-actions {
|
| 112 |
background: var(--card-bg); border: 1px solid var(--card-border); padding: 25px; border-radius: 20px;
|
| 113 |
display: flex; align-items: center; justify-content: space-between; gap: 20px;
|
|
@@ -120,33 +106,31 @@
|
|
| 120 |
}
|
| 121 |
.btn-simulate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(37, 99, 235, 0.6); }
|
| 122 |
|
| 123 |
-
.result-display { font-size: 1.
|
| 124 |
.result-display span { color: #34d399; font-size: 1.8rem; margin-left: 8px; font-weight: 800; }
|
|
|
|
| 125 |
</style>
|
| 126 |
</head>
|
| 127 |
<body>
|
| 128 |
|
| 129 |
<div class="container">
|
| 130 |
<header>
|
| 131 |
-
<h1>Dynamic
|
| 132 |
-
<p>
|
| 133 |
</header>
|
| 134 |
|
| 135 |
-
<!-- Upload Bar -->
|
| 136 |
<div class="upload-bar">
|
| 137 |
<input type="file" id="csvFile" accept=".csv">
|
| 138 |
<button class="btn-primary" onclick="processDataset()">Upload & Parse Dataset</button>
|
| 139 |
</div>
|
| 140 |
|
| 141 |
-
<!-- Navigation Tabs -->
|
| 142 |
<div class="tabs-nav">
|
| 143 |
-
<button id="btn-tab1" class="tab-btn active-btn" onclick="openTab('pane-overview', 'btn-tab1')">Feature Overview & Metrics</button>
|
| 144 |
-
<button id="btn-tab2" class="tab-btn" onclick="openTab('pane-simulator', 'btn-tab2')">Operational Simulator</button>
|
| 145 |
</div>
|
| 146 |
|
| 147 |
-
<!-- TAB 1
|
| 148 |
<div id="pane-overview" class="tab-pane active-pane">
|
| 149 |
-
<!-- Top Metrics Cards -->
|
| 150 |
<div class="metrics-grid">
|
| 151 |
<div class="metric-card card-c1">
|
| 152 |
<div class="metric-title">Total Records</div>
|
|
@@ -166,7 +150,6 @@
|
|
| 166 |
</div>
|
| 167 |
</div>
|
| 168 |
|
| 169 |
-
<!-- Categorical / Numerical Split -->
|
| 170 |
<div class="feature-grid">
|
| 171 |
<div class="feature-box">
|
| 172 |
<h3>Categorical Features</h3>
|
|
@@ -179,17 +162,19 @@
|
|
| 179 |
</div>
|
| 180 |
</div>
|
| 181 |
|
| 182 |
-
<!-- TAB 2
|
| 183 |
<div id="pane-simulator" class="tab-pane">
|
| 184 |
<div class="sliders-grid" id="slider-container">
|
| 185 |
-
<p style="color: var(--text-secondary);">Upload a dataset to
|
| 186 |
</div>
|
| 187 |
|
| 188 |
-
<!-- Simulator CTA -->
|
| 189 |
<div class="simulator-actions">
|
| 190 |
-
<
|
|
|
|
|
|
|
|
|
|
| 191 |
<div class="result-display">
|
| 192 |
-
|
| 193 |
</div>
|
| 194 |
</div>
|
| 195 |
</div>
|
|
@@ -197,6 +182,7 @@
|
|
| 197 |
|
| 198 |
<script>
|
| 199 |
let currentRatings = {};
|
|
|
|
| 200 |
|
| 201 |
function openTab(paneId, btnId) {
|
| 202 |
document.querySelectorAll('.tab-pane').forEach(el => el.classList.remove('active-pane'));
|
|
@@ -217,25 +203,23 @@
|
|
| 217 |
|
| 218 |
if (data.error) return alert(data.error);
|
| 219 |
|
| 220 |
-
// Populate
|
| 221 |
document.getElementById('val-records').innerText = data.metrics.total_records;
|
| 222 |
document.getElementById('val-satisfied').innerText = data.metrics.satisfied_percent;
|
| 223 |
document.getElementById('val-churn').innerText = data.metrics.churn_risk_rate;
|
| 224 |
document.getElementById('val-rating').innerText = data.metrics.journey_rating;
|
|
|
|
| 225 |
|
| 226 |
-
//
|
| 227 |
-
|
| 228 |
-
catList.innerHTML = data.categorical
|
| 229 |
? data.categorical.map(c => `<li>${c}</li>`).join('')
|
| 230 |
: '<li>None found</li>';
|
| 231 |
|
| 232 |
-
|
| 233 |
-
const numList = document.getElementById('num-list');
|
| 234 |
-
numList.innerHTML = data.numerical
|
| 235 |
? data.numerical.map(n => `<li>${n}</li>`).join('')
|
| 236 |
: '<li>None found</li>';
|
| 237 |
|
| 238 |
-
//
|
| 239 |
const sliderContainer = document.getElementById('slider-container');
|
| 240 |
sliderContainer.innerHTML = '';
|
| 241 |
currentRatings = data.ratings || {};
|
|
@@ -252,14 +236,20 @@
|
|
| 252 |
});
|
| 253 |
runSimulation();
|
| 254 |
} else {
|
| 255 |
-
sliderContainer.innerHTML = '<p style="color: var(--text-secondary);">
|
| 256 |
document.getElementById('satisfaction-score').innerText = 'N/A';
|
| 257 |
}
|
| 258 |
}
|
| 259 |
|
|
|
|
| 260 |
function updateSliderVal(col, val, max) {
|
| 261 |
document.getElementById(`val-${col}`).innerText = `${val} / ${max}`;
|
| 262 |
currentRatings[col].default = parseInt(val);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 263 |
}
|
| 264 |
|
| 265 |
async function runSimulation() {
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Dynamic AI Analytics & Operational Simulator</title>
|
| 7 |
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap" rel="stylesheet">
|
| 8 |
<style>
|
| 9 |
:root {
|
|
|
|
| 22 |
body { background-color: var(--bg-main); color: var(--text-primary); padding: 30px 20px; min-height: 100vh; }
|
| 23 |
.container { max-width: 1200px; margin: 0 auto; }
|
| 24 |
|
|
|
|
| 25 |
header { margin-bottom: 30px; text-align: center; }
|
| 26 |
header h1 { font-size: 2.2rem; font-weight: 800; background: linear-gradient(135deg, #60a5fa, #c084fc); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
|
| 27 |
header p { color: var(--text-secondary); margin-top: 6px; font-size: 0.95rem; }
|
| 28 |
|
|
|
|
| 29 |
.upload-bar {
|
| 30 |
background: var(--card-bg);
|
| 31 |
border: 1px solid var(--card-border);
|
|
|
|
| 48 |
}
|
| 49 |
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5); }
|
| 50 |
|
| 51 |
+
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 35px; }
|
|
|
|
| 52 |
.metric-card {
|
| 53 |
background: var(--card-bg);
|
| 54 |
border: 1px solid var(--card-border);
|
| 55 |
backdrop-filter: blur(12px);
|
| 56 |
border-radius: 18px;
|
| 57 |
+
padding: 20px;
|
| 58 |
position: relative;
|
| 59 |
overflow: hidden;
|
| 60 |
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
|
| 61 |
}
|
| 62 |
+
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
|
|
|
|
|
|
|
| 63 |
.card-c1::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
|
| 64 |
.card-c2::before { background: linear-gradient(90deg, #10b981, #34d399); }
|
| 65 |
.card-c3::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
|
| 66 |
.card-c4::before { background: linear-gradient(90deg, #a855f7, #c084fc); }
|
| 67 |
|
| 68 |
+
.metric-title { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }
|
| 69 |
+
.metric-value { font-size: 2rem; font-weight: 800; margin-top: 8px; color: #fff; }
|
| 70 |
|
|
|
|
| 71 |
.tabs-nav { display: flex; gap: 10px; margin-bottom: 25px; border-bottom: 1px solid var(--card-border); padding-bottom: 10px; }
|
| 72 |
.tab-btn {
|
| 73 |
background: transparent; color: var(--text-secondary); border: none; padding: 12px 24px;
|
|
|
|
| 75 |
}
|
| 76 |
.tab-btn.active-btn { background: var(--accent-blue); color: white; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4); }
|
| 77 |
|
|
|
|
| 78 |
.tab-pane { display: none; }
|
| 79 |
.tab-pane.active-pane { display: block; }
|
| 80 |
|
|
|
|
| 81 |
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
|
| 82 |
+
.feature-box { background: var(--card-bg); border: 1px solid var(--card-border); padding: 25px; border-radius: 18px; }
|
|
|
|
|
|
|
| 83 |
.feature-box h3 { font-size: 1.1rem; margin-bottom: 15px; color: var(--text-primary); }
|
| 84 |
.feature-box ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
|
| 85 |
.feature-box li {
|
|
|
|
| 87 |
padding: 6px 14px; border-radius: 50px; font-size: 0.85rem; color: #cbd5e1;
|
| 88 |
}
|
| 89 |
|
| 90 |
+
.sliders-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 30px; }
|
| 91 |
+
.slider-card { background: var(--card-bg); border: 1px solid var(--card-border); padding: 18px; border-radius: 14px; }
|
|
|
|
|
|
|
|
|
|
| 92 |
.slider-card label { display: flex; justify-content: space-between; font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; }
|
| 93 |
input[type="range"] {
|
| 94 |
width: 100%; height: 6px; background: #334155; border-radius: 5px; outline: none; accent-color: var(--accent-blue);
|
| 95 |
}
|
| 96 |
|
|
|
|
| 97 |
.simulator-actions {
|
| 98 |
background: var(--card-bg); border: 1px solid var(--card-border); padding: 25px; border-radius: 20px;
|
| 99 |
display: flex; align-items: center; justify-content: space-between; gap: 20px;
|
|
|
|
| 106 |
}
|
| 107 |
.btn-simulate:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(37, 99, 235, 0.6); }
|
| 108 |
|
| 109 |
+
.result-display { font-size: 1.1rem; font-weight: 700; color: #fff; }
|
| 110 |
.result-display span { color: #34d399; font-size: 1.8rem; margin-left: 8px; font-weight: 800; }
|
| 111 |
+
.ml-badge { font-size: 0.8rem; padding: 4px 10px; background: rgba(124, 58, 237, 0.2); border: 1px solid #7c3aed; color: #c084fc; border-radius: 20px; margin-left: 10px; }
|
| 112 |
</style>
|
| 113 |
</head>
|
| 114 |
<body>
|
| 115 |
|
| 116 |
<div class="container">
|
| 117 |
<header>
|
| 118 |
+
<h1>Dynamic AI Analytics & Real-Time Simulator</h1>
|
| 119 |
+
<p>Scikit-Learn Machine Learning inference pipeline for passenger satisfaction prediction</p>
|
| 120 |
</header>
|
| 121 |
|
|
|
|
| 122 |
<div class="upload-bar">
|
| 123 |
<input type="file" id="csvFile" accept=".csv">
|
| 124 |
<button class="btn-primary" onclick="processDataset()">Upload & Parse Dataset</button>
|
| 125 |
</div>
|
| 126 |
|
|
|
|
| 127 |
<div class="tabs-nav">
|
| 128 |
+
<button id="btn-tab1" class="tab-btn active-btn" onclick="openTab('pane-overview', 'btn-tab1')">Feature Overview & KPI Metrics</button>
|
| 129 |
+
<button id="btn-tab2" class="tab-btn" onclick="openTab('pane-simulator', 'btn-tab2')">ML Operational Simulator</button>
|
| 130 |
</div>
|
| 131 |
|
| 132 |
+
<!-- TAB 1 -->
|
| 133 |
<div id="pane-overview" class="tab-pane active-pane">
|
|
|
|
| 134 |
<div class="metrics-grid">
|
| 135 |
<div class="metric-card card-c1">
|
| 136 |
<div class="metric-title">Total Records</div>
|
|
|
|
| 150 |
</div>
|
| 151 |
</div>
|
| 152 |
|
|
|
|
| 153 |
<div class="feature-grid">
|
| 154 |
<div class="feature-box">
|
| 155 |
<h3>Categorical Features</h3>
|
|
|
|
| 162 |
</div>
|
| 163 |
</div>
|
| 164 |
|
| 165 |
+
<!-- TAB 2 -->
|
| 166 |
<div id="pane-simulator" class="tab-pane">
|
| 167 |
<div class="sliders-grid" id="slider-container">
|
| 168 |
+
<p style="color: var(--text-secondary);">Upload a dataset to activate ML controls.</p>
|
| 169 |
</div>
|
| 170 |
|
|
|
|
| 171 |
<div class="simulator-actions">
|
| 172 |
+
<div style="display: flex; align-items: center;">
|
| 173 |
+
<button class="btn-simulate" onclick="runSimulation()">Simulate Impact</button>
|
| 174 |
+
<span class="ml-badge" id="ml-acc-badge">RandomForest ML: Inactive</span>
|
| 175 |
+
</div>
|
| 176 |
<div class="result-display">
|
| 177 |
+
ML Predicted Satisfaction: <span id="satisfaction-score">N/A</span>
|
| 178 |
</div>
|
| 179 |
</div>
|
| 180 |
</div>
|
|
|
|
| 182 |
|
| 183 |
<script>
|
| 184 |
let currentRatings = {};
|
| 185 |
+
let debounceTimer = null;
|
| 186 |
|
| 187 |
function openTab(paneId, btnId) {
|
| 188 |
document.querySelectorAll('.tab-pane').forEach(el => el.classList.remove('active-pane'));
|
|
|
|
| 203 |
|
| 204 |
if (data.error) return alert(data.error);
|
| 205 |
|
| 206 |
+
// Populate KPIs
|
| 207 |
document.getElementById('val-records').innerText = data.metrics.total_records;
|
| 208 |
document.getElementById('val-satisfied').innerText = data.metrics.satisfied_percent;
|
| 209 |
document.getElementById('val-churn').innerText = data.metrics.churn_risk_rate;
|
| 210 |
document.getElementById('val-rating').innerText = data.metrics.journey_rating;
|
| 211 |
+
document.getElementById('ml-acc-badge').innerText = `RandomForest ML Accuracy: ${data.metrics.model_accuracy}`;
|
| 212 |
|
| 213 |
+
// Populate Features
|
| 214 |
+
document.getElementById('cat-list').innerHTML = data.categorical
|
|
|
|
| 215 |
? data.categorical.map(c => `<li>${c}</li>`).join('')
|
| 216 |
: '<li>None found</li>';
|
| 217 |
|
| 218 |
+
document.getElementById('num-list').innerHTML = data.numerical
|
|
|
|
|
|
|
| 219 |
? data.numerical.map(n => `<li>${n}</li>`).join('')
|
| 220 |
: '<li>None found</li>';
|
| 221 |
|
| 222 |
+
// Render Sliders
|
| 223 |
const sliderContainer = document.getElementById('slider-container');
|
| 224 |
sliderContainer.innerHTML = '';
|
| 225 |
currentRatings = data.ratings || {};
|
|
|
|
| 236 |
});
|
| 237 |
runSimulation();
|
| 238 |
} else {
|
| 239 |
+
sliderContainer.innerHTML = '<p style="color: var(--text-secondary);">No numerical rating features detected for ML simulation.</p>';
|
| 240 |
document.getElementById('satisfaction-score').innerText = 'N/A';
|
| 241 |
}
|
| 242 |
}
|
| 243 |
|
| 244 |
+
// Debounced slider handler to eliminate UI lag
|
| 245 |
function updateSliderVal(col, val, max) {
|
| 246 |
document.getElementById(`val-${col}`).innerText = `${val} / ${max}`;
|
| 247 |
currentRatings[col].default = parseInt(val);
|
| 248 |
+
|
| 249 |
+
clearTimeout(debounceTimer);
|
| 250 |
+
debounceTimer = setTimeout(() => {
|
| 251 |
+
runSimulation();
|
| 252 |
+
}, 150);
|
| 253 |
}
|
| 254 |
|
| 255 |
async function runSimulation() {
|