Published
Edited
Apr 4, 2022
1 fork
14 stars
Also listed in…
Plot Examples
Plot
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
result = `${testname}_result`
Insert cell
roc = d3.sort(d3.shuffle(data.filter((d) => d[result] >= 0)), (d) => d[result])
Insert cell
threshold = (roc[threshold_i][result] + roc[threshold_i + 1][result]) / 2
Insert cell
// this is the threshold value where the test's interpretation changes (from "NOT detected" to "DETECTED")
threshold_i = {
const interpretation = `${testname}_interpretation`;
for (let i = 0; i < roc.length - 1; i++)
if (roc[i][interpretation] !== roc[i + 1][interpretation]) return i;

// for random and ideal, set the threshold at the number of true negative
return N - 1;
}
Insert cell
T = Uint8Array.from(roc, (d) => +(d.status === "P"))
Insert cell
X = d3.cumsum(T)
Insert cell
P = X[T.length - 1] // equiv. d3.sum(T)
Insert cell
Y = X.map((x, i) => 1 + i - x) // equiv. d3.cumsum(T, t => 1 - t)
Insert cell
N = Y[T.length - 1] // equiv. d3.sum(T, t => 1 - t)
Insert cell
AUC = 1 - d3.sum(T, (t, i) => (1 - t) * X[i]) / (N * P)
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("supplementary_dataset2.xlsx")
.xlsx()
.then((xl) => xl.sheet("all_samples", { headers: true }))
.then(
(data) => (
data.forEach((d) => {
d.status = d.samplecollection === "obb_negatives" ? "N" : "P";

d.status_result = 1 + +(d.status === "P");

d.diasorin_result =
d.diasorin_result[0] === "<"
? +d.diasorin_result.slice(1).trim()
: d.diasorin_result;

d.siemens_result =
d.siemens_result[0] === "<"
? +d.siemens_result.slice(1).trim()
: d.siemens_result;

d.random_result = random();
}),
data
)
)
Insert cell
random = d3.randomExponential(1)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more