Add timeline insight metrics

This commit is contained in:
dahyeon committed 2026-07-03 00:29:51 -07:00
1 parent a69e86f2bc
commit 1a7a1cca68
5 files changed
+1328 -5

No files matched your search

+112 -3
View File
@@ -41,7 +41,26 @@ const MVP_2_TIMELINE_METRIC_IDS = [
'deathWithShutdownBountyGivenRate',
'ccTimePerMinute',
];
const MVP_2_METRIC_IDS = [...MVP_1_METRIC_IDS, ...MVP_2_TIMELINE_METRIC_IDS];
const MVP_2_INSIGHT_METRIC_IDS = [
'objectiveFightOpeningParticipationRate',
'objectiveFightOpeningConvertedToObjectiveRate',
'preObjectivePitPresenceRate',
'preObjectivePickParticipationRate',
'deathFollowedByTeamLossRate',
'deathTradedForTeamAdvantageRate',
'deathWhileIsolatedFromNearestAllyRate',
'earlyDeficitRecoveryRate',
'laneLeadConversionRate',
'roamConvertedToTeamAdvantageRate',
'shutdownGoldCollectedPerGame',
'platePresenceParticipationRate',
'objectiveBountyComebackParticipationRate',
];
const MVP_2_METRIC_IDS = [
...MVP_1_METRIC_IDS,
...MVP_2_TIMELINE_METRIC_IDS,
...MVP_2_INSIGHT_METRIC_IDS,
];
const MVP_2_TIMELINE_METRIC_CONTRACTS = [
{ id: 'goldDiffAt10', kind: 'scalar', direction: 'higherIsBetter' },
{ id: 'goldDiffAt14', kind: 'scalar', direction: 'higherIsBetter' },
@@ -78,24 +97,95 @@ const MVP_2_TIMELINE_METRIC_CONTRACTS = [
},
{ id: 'ccTimePerMinute', kind: 'scalar', direction: 'higherIsBetter' },
] as const;
const MVP_2_INSIGHT_METRIC_CONTRACTS = [
{
id: 'objectiveFightOpeningParticipationRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'objectiveFightOpeningConvertedToObjectiveRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'preObjectivePitPresenceRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'preObjectivePickParticipationRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'deathFollowedByTeamLossRate',
kind: 'ratio',
direction: 'lowerIsBetter',
},
{
id: 'deathTradedForTeamAdvantageRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'deathWhileIsolatedFromNearestAllyRate',
kind: 'ratio',
direction: 'lowerIsBetter',
},
{
id: 'earlyDeficitRecoveryRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'laneLeadConversionRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'roamConvertedToTeamAdvantageRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'shutdownGoldCollectedPerGame',
kind: 'scalar',
direction: 'higherIsBetter',
},
{
id: 'platePresenceParticipationRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
{
id: 'objectiveBountyComebackParticipationRate',
kind: 'ratio',
direction: 'higherIsBetter',
},
] as const;
describe('shared feature registry', () => {
it('defines MVP 2 vector metrics in the documented order', () => {
expect(FEATURE_SCHEMA_VERSION).toBe(2);
expect(METRICS.map((metric) => metric.id)).toEqual(MVP_2_METRIC_IDS);
expect(VECTOR_DIMENSION).toBe(26);
expect(
METRICS.filter((metric) => metric.includeInVector).map(
(metric) => metric.id,
),
).toEqual([...MVP_1_METRIC_IDS, ...MVP_2_TIMELINE_METRIC_IDS]);
expect(METRICS.filter((metric) => metric.includeInVector)).toHaveLength(
VECTOR_DIMENSION,
);
});
it('keeps metric ids unique and every vector metric normalizable by role', () => {
it('keeps metric ids unique and every metric normalizable by role', () => {
const metricIds = METRICS.map((metric) => metric.id);
expect(new Set(metricIds).size).toBe(metricIds.length);
for (const metric of METRICS) {
expect(metric.label).toBeTruthy();
expect(metric.includeInVector).toBe(true);
expect(metric.baseline).toBeDefined();
expect(Object.keys(metric.baseline ?? {}).sort()).toEqual([
'BOTTOM',
@@ -140,6 +230,25 @@ describe('shared feature registry', () => {
);
});
it('defines MVP 2 insight metric aggregation contracts outside the vector', () => {
expect(
MVP_2_INSIGHT_METRIC_IDS.map((metricId) => {
const metric = METRICS.find((candidate) => candidate.id === metricId);
return {
id: metric?.id,
kind: metric?.kind,
direction: metric?.direction,
includeInVector: metric?.includeInVector,
};
}),
).toEqual(
MVP_2_INSIGHT_METRIC_CONTRACTS.map((metric) => ({
...metric,
includeInVector: false,
})),
);
});
it('defines shared advantage event weights for timeline-derived metrics', () => {
expect(ADVANTAGE_EVENT_WEIGHTS).toEqual({
championKill: 1,