milia.recommend.diagnostics#
Diagnostics for whether entity-level retrieval makes sense.
Functions
|
Within-entity variance against overall variance, per metric. |
- milia.recommend.diagnostics.variance(frame, group, metrics)#
Within-entity variance against overall variance, per metric.
A ratio near 1 means repeated draws for the same entity vary as much as the population does, so the entity carries little information about the outcome (location or chance drives it); a ratio near 0 means the entity largely determines it and retrieval by similarity can work.
- Parameters:
- Return type:
- Returns:
One row per metric with
within,overallandratio.
Examples
>>> import pandas as pd >>> frame = pd.DataFrame({"id": [1, 1, 2, 2], "risk": [1.0, 1.1, 5.0, 5.1]}) >>> float(variance(frame, "id", ["risk"])["ratio"].round(4).item()) 0.0009