Skip to content

Persist trained models in localStorage across reloads #8

Description

@jeanclawd

Problem

A reload (intentional or accidental) wipes every trained model. Re-training a Random Forest on a 5 MB CSV takes 30-60 s — frustrating when it happens by mistake.

Proposal

After a successful train, serialise the `trainedModels` state (model ID, hyperparams, metrics, optionally the joblib bytes) to `localStorage` keyed by `(dataset_id, feature_set_hash)`. On page load, restore the metrics and let the user re-render charts without re-training.

Scope decisions

  • Metrics + config are cheap to persist (a few KB) — do this in v1.
  • Trained model bytes (joblib) can be large (MB-scale). Either skip them in v1 (re-train on demand) or persist behind a feature flag.
  • Cap localStorage usage at ~5 MB; evict oldest entries when over.

Implementation notes

  • New helpers `saveState()` / `loadState()` in `frontend/js/app.js`.
  • A small "restored from previous session" toast on load when state is rehydrated.
  • A "Clear cached models" button in settings.

Acceptance criteria

  • Train a model, reload, see the same metrics and chart without re-training.
  • Switching dataset clears the displayed models cleanly.
  • Storage stays under 5 MB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions