Dsxir. Predictor. Ensemble
(dsxir v0.4.0)
Copy Markdown
Runs N programs concurrently over the same inputs and reduces their
predictions. Invoked directly from a forward/2 body, like
Dsxir.Predictor.Parallel; it is not a declared predictor.
Members fan out under Dsxir.TaskSupervisor via
Task.Supervisor.async_stream_nolink/4, replaying the caller's
Dsxir.Settings.snapshot/0 in each worker. Member failures are tolerated and
surfaced via telemetry; the reduction runs over the survivors. When every
member fails, run/3 raises Dsxir.Errors.Framework.PredictorError with
reason: :all_failed.
Recognised opts
:reduce_fn—([Dsxir.Prediction.t()] -> Dsxir.Prediction.t()). Whennil(default),run/3returns the raw prediction list; otherwise it returns the reduced prediction.:size— sample this many programs per call. Defaults to all.:max_concurrency— defaults toSystem.schedulers_online().:timeout— per-member timeout in ms. Defaults to30_000.
Return shape
Unlike the rest of the predictor namespace, run/3 returns a bare
%Dsxir.Prediction{} (with a reducer) or a [%Dsxir.Prediction{}] (without
one) rather than a {program, prediction} tuple — there is no single program
identity across N members.
Iron Law of OTP
Workers are short-lived Tasks with no state across calls; concurrency is
the purpose (independent members); fault isolation is required, hence
async_stream_nolink so a member crash does not link back to the caller, and
on_timeout: :kill_task reaps slow members. No process is held; the reducer
is pure.
Summary
Functions
Majority-vote reducer. Votes on the full fields map, or a single field via field:. Ties break by first occurrence.
Run each program in programs over inputs concurrently and reduce the survivors.
Functions
@spec majority( [Dsxir.Prediction.t()], keyword() ) :: Dsxir.Prediction.t()
Majority-vote reducer. Votes on the full fields map, or a single field via field:. Ties break by first occurrence.
@spec run([Dsxir.Program.t()], map(), keyword()) :: Dsxir.Prediction.t() | [Dsxir.Prediction.t()]
Run each program in programs over inputs concurrently and reduce the survivors.