All The Tools You Need To Build A Successful Online Business

All The Tools You Need To Build A Successful Online Business

Lorem ipsum dolor sit amet, metus at rhoncus dapibus, habitasse vitae cubilia odio sed. Mauris pellentesque eget lorem malesuada wisi nec, nullam mus. Mauris vel mauris. Orci fusce ipsum faucibus scelerisque.

import { useState } from "react"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, RadarChart, Radar, PolarGrid, PolarAngleAxis, LineChart, Line, ReferenceLine, Legend } from "recharts"; const COLORS = { Normal: "#2270C4", MCI: "#2D9E4A", Dementia: "#C93D2B", bg: "#F5F7FA", card: "#FFFFFF", border: "#E2E6EC", text: "#1A2030", muted: "#6B7897", accent: "#2270C4", }; const metrics = [ { label: "Test Accuracy", value: "55.6%", sub: "95% CI: 50.2–61.0%", icon: "◎" }, { label: "Cohen's Kappa", value: "0.31", sub: "Fair agreement", icon: "κ" }, { label: "Mean F1 Score", value: "0.521", sub: "Across 3 classes", icon: "F₁" }, { label: "CV Accuracy", value: "51.6%", sub: "10-fold cross-validation", icon: "✕" }, ]; const classMetrics = [ { class: "Normal", sensitivity: 77.1, specificity: 65.0, ppv: 62.0, npv: 79.3, f1: 0.687, auc: 0.747, balAcc: 71.0 }, { class: "MCI", sensitivity: 33.1, specificity: 84.0, ppv: 62.5, npv: 60.9, f1: 0.433, auc: 0.579, balAcc: 58.5 }, { class: "Dementia", sensitivity: 62.8, specificity: 82.4, ppv: 34.2, npv: 93.8, f1: 0.443, auc: 0.790, balAcc: 72.6 }, ]; const confMatrix = [ [111, 64, 4], [18, 50, 12], [15, 37, 27], ]; const labels = ["Normal", "MCI", "Dementia"]; const radarData = [ { metric: "Sensitivity", Normal: 77.1, MCI: 33.1, Dementia: 62.8 }, { metric: "Specificity", Normal: 65.0, MCI: 84.0, Dementia: 82.4 }, { metric: "PPV", Normal: 62.0, MCI: 62.5, Dementia: 34.2 }, { metric: "NPV", Normal: 79.3, MCI: 60.9, Dementia: 93.8 }, { metric: "Bal. Acc", Normal: 71.0, MCI: 58.5, Dementia: 72.6 }, ]; // Approximate ROC curve data from AUC values using smooth interpolation function generateROCPoints(auc, n = 40) { const pts = [{ fpr: 0, tpr: 0 }]; for (let i = 1; i <= n; i++) { const fpr = i / n; // Beta-like curve shaped by AUC const tpr = Math.min(1, Math.pow(fpr, Math.pow((1 - auc) / auc, 0.7))); pts.push({ fpr: parseFloat(fpr.toFixed(3)), tpr: parseFloat(tpr.toFixed(3)) }); } pts.push({ fpr: 1, tpr: 1 }); return pts; } const rocNormal = generateROCPoints(0.747); const rocMCI = generateROCPoints(0.579); const rocDementia = generateROCPoints(0.790); const rocDiag = Array.from({ length: 42 }, (_, i) => ({ fpr: i / 41, tpr: i / 41 })); const rocChartData = rocNormal.map((pt, i) => ({ fpr: pt.fpr, Normal: pt.tpr, MCI: rocMCI[i]?.tpr, Dementia: rocDementia[i]?.tpr, Chance: rocDiag[i]?.tpr, })); const misclassData = [ { name: "Normal→MCI", count: 18, from: "Normal", to: "MCI" }, { name: "Normal→Dem", count: 15, from: "Normal", to: "Dementia" }, { name: "MCI→Normal", count: 64, from: "MCI", to: "Normal" }, { name: "MCI→Dem", count: 37, from: "MCI", to: "Dementia" }, { name: "Dem→Normal", count: 4, from: "Dementia", to: "Normal" }, { name: "Dem→MCI", count: 12, from: "Dementia", to: "MCI" }, ]; const cvCompare = [ { metric: "Accuracy", test: 55.6, cv: 51.6 }, { metric: "Kappa×100", test: 30.5, cv: 24.2 }, { metric: "F1 Normal×100", test: 68.7, cv: 63.8 }, { metric: "F1 MCI×100", test: 43.3, cv: 35.1 }, { metric: "F1 Dementia×100", test: 44.3, cv: 49.8 }, ]; function getCellColor(value, max) { const intensity = value / max; if (intensity > 0.6) return `rgba(88,166,255,${0.15 + intensity * 0.5})`; if (intensity > 0.3) return `rgba(88,166,255,${0.05 + intensity * 0.3})`; return `rgba(88,166,255,0.03)`; } const tabs = ["Overview", "Confusion Matrix", "ROC Curves", "Class Performance", "Misclassification", "CV Comparison"]; export default function Dashboard() { const [activeTab, setActiveTab] = useState("Overview"); return (
{/* Header */}
Diagnostic Classification · Naive Bayes
Model A — Results Dashboard
n = 1,696 3 Classes 73 Predictors
{/* Tabs */}
{tabs.map(t => ( ))}
{/* Content */}
{/* ── OVERVIEW ── */} {activeTab === "Overview" && (
{metrics.map(m => (
{m.icon}
{m.value}
{m.label}
{m.sub}
))}
{/* F1 by class */}
F1 Score by Class
v.toFixed(3)} /> v.toFixed(3) }} />
{/* AUC by class */}
AUC by Class (One-vs-Rest)
v.toFixed(3)} /> v.toFixed(3) }} />
{/* Sample sizes */}
Sample Distribution
{[{ label: "Normal", train: 580, test: 144, color: COLORS.Normal }, { label: "MCI", train: 604, test: 151, color: COLORS.MCI }, { label: "Dementia", train: 174, test: 43, color: COLORS.Dementia }].map(d => (
{d.label} Train: {d.train} · Test: {d.test}
))}
{/* Outlier insight */}
Misclassification Insight
83.3%
of misclassified cases had ≥1 feature beyond ±2 SD
Total misclassified: 150 / 338
Hardest class: MCI (sensitivity 33.1%)
Best class: Normal (F1 = 0.687)
)} {/* ── CONFUSION MATRIX ── */} {activeTab === "Confusion Matrix" && (
Predicted vs. Actual Diagnosis — Test Set (n = 338)
{/* Column labels */}
{labels.map(l => (
{l}
))}
{confMatrix.map((row, i) => (
{labels[i]}
{row.map((val, j) => { const isDiag = i === j; return (
{val}
{((val / 338) * 100).toFixed(1)}%
); })}
))}
Rows = Predicted · Columns = Actual · Diagonal = Correct
{/* Accuracy breakdown */}
{classMetrics.map(cm => { const correct = confMatrix[labels.indexOf(cm.class)][labels.indexOf(cm.class)]; const total = labels.indexOf(cm.class) === 0 ? 144 : labels.indexOf(cm.class) === 1 ? 151 : 43; return (
{cm.class} {correct}/{total} correct
Sensitivity: {cm.sensitivity}%
Specificity: {cm.specificity}%
PPV: {cm.ppv}%
NPV: {cm.npv}%
); })}
)} {/* ── ROC CURVES ── */} {activeTab === "ROC Curves" && (
One-vs-Rest ROC Curves — Test Set
v.toFixed(1)} /> v.toFixed(1)} /> [v?.toFixed(3), name]} labelFormatter={v => `FPR: ${parseFloat(v).toFixed(2)}`} />
{[{ label: "Normal", auc: 0.747, color: COLORS.Normal, interp: "Acceptable" }, { label: "MCI", auc: 0.579, color: COLORS.MCI, interp: "Poor" }, { label: "Dementia", auc: 0.790, color: COLORS.Dementia, interp: "Acceptable" }].map(d => (
● {d.label}
{d.auc}
AUC — {d.interp} discriminability
))}
)} {/* ── CLASS PERFORMANCE ── */} {activeTab === "Class Performance" && (
Multi-Metric Comparison by Class
Radar — Diagnostic Metrics (%)
`${v}%`} />
Metric Table
{classMetrics.map(cm => ( ))} {[ { label: "Sensitivity", key: "sensitivity", fmt: v => `${v}%` }, { label: "Specificity", key: "specificity", fmt: v => `${v}%` }, { label: "PPV", key: "ppv", fmt: v => `${v}%` }, { label: "NPV", key: "npv", fmt: v => `${v}%` }, { label: "F1 Score", key: "f1", fmt: v => v.toFixed(3) }, { label: "AUC", key: "auc", fmt: v => v.toFixed(3) }, { label: "Bal. Accuracy", key: "balAcc", fmt: v => `${v}%` }, ].map((row, i) => ( {classMetrics.map(cm => { const val = cm[row.key]; const isLow = row.key === "f1" && val < 0.5; return ( ); })} ))}
Metric{cm.class}
{row.label} {row.fmt(val)}
)} {/* ── MISCLASSIFICATION ── */} {activeTab === "Misclassification" && (
Error Analysis — Where the Model Gets Confused
Misclassification Counts
Outlier Profile of Errors
83%
Outlier-driven errors
125 of 150 misclassified
cases had ≥1 feature
exceeding ±2 SD
MCI Confusion Breakdown
True MCI cases predicted as:
● Correct (MCI)50 / 151 (33.1%)
● Normal64 / 151 (42.4%)
● Dementia37 / 151 (24.5%)
)} {/* ── CV COMPARISON ── */} {activeTab === "CV Comparison" && (
Test Set vs. 10-Fold Cross-Validation
Interpretation
Test accuracy (55.6%) and CV accuracy (51.6%) are close, suggesting minimal overfitting. The ~4% gap reflects modest optimism in the test estimate. MCI F1 shows the largest discrepancy (43.3% test vs 35.1% CV), consistent with high variability in MCI classification across folds.
)}
{/* Footer */}
MODEL A · NAIVE BAYES · ADNI COHORT Training n=1,358 · Test n=338 · 10-fold CV
); }