Skip to content

Algorithms overview

Framework algorithms implement reusable computation. They accept in-memory data and return result DTOs; they do not open datasets or choose workflow policy.

from drtoller.framework.algorithms import embed_rows, cluster_vectors, cluster_with_k

Embedding and clustering dispatch by registered method_id. Dataset metrics use a separate capability registry.

compute.* defaults/user params compile into ComputePlan. A processor or execution mode prepares inputs and invokes the selected method. DRTML does not execute an arbitrary algorithm automatically.

plan = parse_compute_plan(params)
result = cluster_with_k(
vectors,
row_ids,
chosen_k,
method_id=plan.cluster.method_id,
params=cluster_algorithm_kwargs(plan),
)
rows = [
{"row_id": rid, "cluster_id": int(label)}
for rid, label in zip(result.row_ids, result.labels)
]
return [ProcessResult(ok=True, rows={"assignments": rows})]

Domain code owns chosen_k, probe loops and early stopping. Framework owns the clustering implementation.