Spaces:
Running
Running
Download frontends/react/src/models.ts from nhamid289/decision_boundary-dev: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/nhamid289/decision_boundary-dev/resolve/main/frontends/react/src/models.ts
- Command line
-
hf download hf://spaces/nhamid289/decision_boundary-dev/frontends/react/src/models.ts
-
curl -L -o models.ts https://huggingface.co/spaces/nhamid289/decision_boundary-dev/resolve/main/frontends/react/src/models.ts
1.4 kB
| import type { ModelSpec, ParamSpec } from "@elvis/ui"; | |
| import spec from "../../../backend/src/models.json"; | |
| import generated from "../../../backend/src/sklearn_params.json"; | |
| // The models students can choose, from the spec shared with the Python backend: | |
| // models.json picks the settings shown first, sklearn_params.json has the rest. | |
| // JSON imports type "kind" as string, so the specs' shape is checked by | |
| // backend/tests/test_models.py rather than here. | |
| const allParams = generated.models as unknown as Record<string, ParamSpec[]>; | |
| export const MODELS: ModelSpec[] = spec.models.map((model) => { | |
| const shown = new Set(model.params.map((p) => p.name)); | |
| const library = allParams[model.id] ?? []; | |
| const described = new Map(library.map((p) => [p.name, p.description])); | |
| return { | |
| ...(model as unknown as ModelSpec), | |
| // The panel's settings take their description from scikit-learn's too | |
| params: (model.params as unknown as ParamSpec[]).map((p) => ({ ...p, description: p.description ?? described.get(p.name) })), | |
| // Arguments models.json always passes (e.g. max_iter) start at that value | |
| otherParams: library | |
| .filter((p) => !shown.has(p.name)) | |
| .map((p) => (p.name in model.fixed ? { ...p, default: model.fixed[p.name as keyof typeof model.fixed] } as ParamSpec : p)), | |
| libraryDefaults: Object.fromEntries(library.map((p) => [p.name, p.default])), | |
| }; | |
| }); | |