Files
Anubis/src/Anubis.Server/Components/WeeklyPrecision.razor
T
Alby96andClaude Opus 5.5 f69943f70a Show what the model knows on its own screen and let the user set it aside
The Apprendimento screen says in plain words whether the model counts, how
well its probabilities hold, which clues it weighs, how the challenger is
doing and what it has learned. Thresholds, set-aside and the undo of a
promotion live in Impostazioni; anything that shrinks less with real money
asks for the phrase. The new tests also caught a wrong column name that
broke the Panoramica as soon as the first model existed.

refs #66

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 12:44:37 +01:00

62 lines
3.4 KiB
Plaintext

@* The precision of the model week by week with the alarm line (SPEC 13.6, mockup 06). Weeks without enough cases leave no
point; the days on the axis keep the distance between the others. *@
@if (Weeks.Count >= 2)
{
var alarm = (decimal)(Anubis.Learning.Health.Alarm * 100);
var lo = Math.Min(Weeks.Min(w => w.Precision), alarm) - 4m;
var hi = Math.Max(Weeks.Max(w => w.Precision), alarm) + 4m;
var (first, last) = (Weeks[0], Weeks[^1]);
var lowest = Weeks.MinBy(w => w.Precision)!;
decimal X(LearningWeek w) => (w.Monday.DayNumber - first.Monday.DayNumber) * 1000m / (last.Monday.DayNumber - first.Monday.DayNumber);
decimal Y(decimal v) => (hi - v) / (hi - lo) * 1000m;
<figure class="weekly" aria-label="Precisione settimana per settimana">
<figcaption class="note">Precisione settimana per settimana</figcaption>
<div class="weekly-box">
<div class="chart-plot">
<svg viewBox="0 0 1000 1000" preserveAspectRatio="none" aria-hidden="true" focusable="false">
<line class="bench" x1="0" x2="1000" y1="@Css(Y(alarm))" y2="@Css(Y(alarm))" vector-effect="non-scaling-stroke" />
<polyline class="equity" points="@string.Join(" ", Weeks.Select(w => Css(X(w)) + "," + Css(Y(w.Precision))))" vector-effect="non-scaling-stroke" />
</svg>
@foreach (var w in Weeks)
{
<span class="end-dot hover-dot @(w == last || w == lowest ? null : "quiet")" style="left:@Pct(X(w) / 10);top:@Pct(Y(w.Precision) / 10)"><span class="hover-box">Settimana del @Day(w.Monday)<br />@w.Precision%</span></span>
}
@if (lowest != last)
{
<span class="point-label under" style="left:@Pct(X(lowest) / 10);top:@Pct(Y(lowest.Precision) / 10)">@lowest.Precision%</span>
}
</div>
<div class="weekly-side" aria-hidden="true">
<strong style="top:@Pct(Math.Min(Y(last.Precision), Y(alarm) - 300m) / 10)">@last.Precision%</strong>
<span style="top:@Pct(Y(alarm) / 10)">allarme<br />sotto @Format.Number(alarm)%</span>
</div>
</div>
<div class="weekly-x note" aria-hidden="true"><span>@Day(first.Monday)</span><span>@Day(last.Monday)</span></div>
<details class="chart-table">
<summary>Vedi i numeri in una tabella</summary>
<div class="table-wrap">
<table class="table">
<thead><tr><th scope="col">Settimana dal lunedì</th><th scope="col" class="num">Precisione</th></tr></thead>
<tbody>
@foreach (var w in Weeks.Reverse())
{
<tr><td>@Format.LongDate(w.Monday)</td><td class="num">@w.Precision%</td></tr>
}
</tbody>
</table>
</div>
</details>
</figure>
}
@code {
[Parameter, EditorRequired]
public IReadOnlyList<LearningWeek> Weeks { get; set; } = [];
private static string Day(DateOnly day) => day.ToString("d MMM", CultureInfo.GetCultureInfo("it-IT"));
private static string Css(decimal v) => v.ToString("0.##", CultureInfo.InvariantCulture);
private static string Pct(decimal v) => v.ToString("0.###", CultureInfo.InvariantCulture) + "%";
}