Add timeline vector metrics
This commit is contained in:
1 parent
77ba93b94a
commit
a69e86f2bc
13 files changed
+1543
-37
No files matched your search
@@ -25,24 +25,76 @@ const MVP_1_METRIC_IDS = [
|
||||
'objectiveParticipation',
|
||||
'soloKills',
|
||||
];
|
||||
const MVP_2_TIMELINE_METRIC_IDS = [
|
||||
'goldDiffAt10',
|
||||
'goldDiffAt14',
|
||||
'csDiffAt10',
|
||||
'xpDiffAt10',
|
||||
'deathsBefore14',
|
||||
'killParticipationBefore14',
|
||||
'earlyWardsPerMin',
|
||||
'objectivePreWardRate',
|
||||
'eliteObjectiveParticipationRate',
|
||||
'isolationTendency',
|
||||
'teamfightFirstEngagementParticipationRate',
|
||||
'teamfightCleanupKillParticipationRate',
|
||||
'deathWithShutdownBountyGivenRate',
|
||||
'ccTimePerMinute',
|
||||
];
|
||||
const MVP_2_METRIC_IDS = [...MVP_1_METRIC_IDS, ...MVP_2_TIMELINE_METRIC_IDS];
|
||||
const MVP_2_TIMELINE_METRIC_CONTRACTS = [
|
||||
{ id: 'goldDiffAt10', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
{ id: 'goldDiffAt14', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
{ id: 'csDiffAt10', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
{ id: 'xpDiffAt10', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
{ id: 'deathsBefore14', kind: 'scalar', direction: 'lowerIsBetter' },
|
||||
{
|
||||
id: 'killParticipationBefore14',
|
||||
kind: 'scalar',
|
||||
direction: 'higherIsBetter',
|
||||
},
|
||||
{ id: 'earlyWardsPerMin', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
{ id: 'objectivePreWardRate', kind: 'ratio', direction: 'higherIsBetter' },
|
||||
{
|
||||
id: 'eliteObjectiveParticipationRate',
|
||||
kind: 'ratio',
|
||||
direction: 'higherIsBetter',
|
||||
},
|
||||
{ id: 'isolationTendency', kind: 'scalar', direction: 'lowerIsBetter' },
|
||||
{
|
||||
id: 'teamfightFirstEngagementParticipationRate',
|
||||
kind: 'ratio',
|
||||
direction: 'higherIsBetter',
|
||||
},
|
||||
{
|
||||
id: 'teamfightCleanupKillParticipationRate',
|
||||
kind: 'ratio',
|
||||
direction: 'higherIsBetter',
|
||||
},
|
||||
{
|
||||
id: 'deathWithShutdownBountyGivenRate',
|
||||
kind: 'ratio',
|
||||
direction: 'lowerIsBetter',
|
||||
},
|
||||
{ id: 'ccTimePerMinute', kind: 'scalar', direction: 'higherIsBetter' },
|
||||
] as const;
|
||||
|
||||
describe('shared feature registry', () => {
|
||||
it('defines MVP 1 vector metrics in the documented order', () => {
|
||||
expect(FEATURE_SCHEMA_VERSION).toBe(1);
|
||||
expect(METRICS.map((metric) => metric.id)).toEqual(MVP_1_METRIC_IDS);
|
||||
expect(VECTOR_DIMENSION).toBe(12);
|
||||
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)).toHaveLength(
|
||||
VECTOR_DIMENSION,
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps metric ids unique and every MVP 1 metric normalizable by role', () => {
|
||||
it('keeps metric ids unique and every vector 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.kind).toBe('scalar');
|
||||
expect(metric.includeInVector).toBe(true);
|
||||
expect(metric.baseline).toBeDefined();
|
||||
expect(Object.keys(metric.baseline ?? {}).sort()).toEqual([
|
||||
@@ -63,6 +115,29 @@ describe('shared feature registry', () => {
|
||||
expect(
|
||||
METRICS.find((metric) => metric.id === 'deathsPerMin')?.direction,
|
||||
).toBe('lowerIsBetter');
|
||||
expect(
|
||||
METRICS.find((metric) => metric.id === 'deathWithShutdownBountyGivenRate')
|
||||
?.direction,
|
||||
).toBe('lowerIsBetter');
|
||||
});
|
||||
|
||||
it('defines MVP 2 timeline metric aggregation contracts', () => {
|
||||
expect(
|
||||
MVP_2_TIMELINE_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_TIMELINE_METRIC_CONTRACTS.map((metric) => ({
|
||||
...metric,
|
||||
includeInVector: true,
|
||||
})),
|
||||
);
|
||||
});
|
||||
|
||||
it('defines shared advantage event weights for timeline-derived metrics', () => {
|
||||
@@ -127,7 +202,7 @@ describe('shared DTO contracts', () => {
|
||||
status: 'queued',
|
||||
};
|
||||
const playstyle = Object.fromEntries(
|
||||
MVP_1_METRIC_IDS.map((metricId) => [metricId, 0.5]),
|
||||
MVP_2_METRIC_IDS.map((metricId) => [metricId, 0.5]),
|
||||
) as PlayerAnalysisDto['profile']['playstyle'];
|
||||
const analysis: PlayerAnalysisDto = {
|
||||
account: {
|
||||
|
||||
Reference in new issue
Block a user