diff --git a/app/lab/kind-cards.tsx b/app/lab/kind-cards.tsx index 4304f3c0..2e16606e 100644 --- a/app/lab/kind-cards.tsx +++ b/app/lab/kind-cards.tsx @@ -11,10 +11,13 @@ import { TimelineBody } from "./timeline-body"; import { AlterationsBody } from "./alterations-body"; import { Checkbox } from "../_ui/checkbox"; import { Input } from "../_ui/input"; -import { OptionSelect } from "../_ui/choice.tsx"; +import { Choice, OptionSelect } from "../_ui/choice.tsx"; import { FIELD } from "../_ui/toolbar.ts"; import { RISK_LABEL_ABOVE } from "../../lib/figures/riskmodel.ts"; +import { RiskTable1Button } from "./risk-table1-dialog.tsx"; import { RiskGroupsButton } from "./risk-groups-dialog.tsx"; +import { GearMenu } from "../_ui/gear-menu"; +import { Settings2 } from "lucide-react"; /** * A text field that keeps what is being typed to itself and hands the page the value only on @@ -118,6 +121,37 @@ export interface KindCardCtx { /** the risk model's covariate menus, open or shut, by view (a viewport state, not the document's) */ const RISK_MENUS = new Map(); +/** the runs the model settings offer (OncoCast recommends 50 or more) */ +const RISK_RUN_STEPS = [5, 10, 20, 50]; +const RISK_PENALTIES: [string, string][] = [["1", "lasso"], ["0.5", "elastic net"], ["0.1", "mostly ridge"]]; + +/** + * The risk model's fitting settings, set once and rarely changed, behind the view's settings menu + * (the sequence and course views' idiom) so the toolbar keeps to what a reader works with. + */ +function RiskModelSettings({ vi, spec, busy, patch }: { vi: number; spec: any; busy: boolean; patch: (p: Record) => void }) { + const alpha = String(spec.alpha ?? 0.5), runs = String(spec.runs ?? 10); + const penalties = RISK_PENALTIES.some(([v]) => v === alpha) ? RISK_PENALTIES : [[alpha, "alpha " + alpha] as [string, string], ...RISK_PENALTIES]; + const runSteps = RISK_RUN_STEPS.map(String); + return ( + settings}> +
+ penalty + patch({ alpha: Number(v) })} options={penalties} /> +
+
+ runs + patch({ runs: Number(v) })} + options={(runSteps.includes(runs) ? runSteps : [runs, ...runSteps]).map((r) => [r, r] as const)} /> +
+ +
+ ); +} + /** the volcano's label thresholds the card offers */ const RISK_LABEL_STEPS = [0.1, 0.25, 0.5, 0.75, 0.9, 1]; @@ -417,8 +451,6 @@ export function KindCardControls({ c }: { c: KindCardCtx }) { {cats.map((a) => )} - -
adjust a.attribute !== spec.strata).map((a) => ({ value: a.attribute, label: a.attribute, hint: a.kind === "num" ? "number" : "category" }))} chosen={spec.covariates || []} max={6} busy={busy} menuId={"risk-cov:" + c.vi} menuStore={RISK_MENUS} @@ -443,20 +475,9 @@ export function KindCardControls({ c }: { c: KindCardCtx }) { }
model - - - + +
view