Add timeline vector metrics

This commit is contained in:
dahyeon committed 2026-07-03 00:12:13 -07:00
1 parent 77ba93b94a
commit a69e86f2bc
13 files changed
+1543 -37

No files matched your search

@@ -35,7 +35,7 @@ function createFeature(
featureSchemaVersion: FEATURE_SCHEMA_VERSION,
normalizationMethod: 'registry-baseline',
confidence: 1,
timelineProcessed: false,
timelineProcessed: true,
...overrides,
};
}
@@ -87,13 +87,16 @@ describe('ProfileBuilderService', () => {
expect(profile.mainRole).toBe('MIDDLE');
expect(profile.sampleGameCount).toBe(2);
for (const metric of METRICS) {
for (const metric of METRICS.filter((metric) => metric.kind === 'scalar')) {
expect(profile.profile[metric.id]).toBeCloseTo(
(firstNormalized[metric.id] + secondNormalized[metric.id] * 0.5) / 1.5,
);
}
for (const metric of METRICS.filter((metric) => metric.kind === 'ratio')) {
expect(profile.profile[metric.id]).toBeUndefined();
}
expect(profile.vector).toEqual(
VECTOR_METRICS.map((metric) => profile.profile[metric.id]),
VECTOR_METRICS.map((metric) => profile.profile[metric.id] ?? 0),
);
expect(profile.championPool).toEqual([
{ championId: 103, games: 1, wins: 1 },
@@ -115,6 +118,20 @@ describe('ProfileBuilderService', () => {
).toThrow('Cannot build a profile without match features.');
});
it('discounts profile confidence when timeline metrics are missing', () => {
const profile = service.buildProfile({
features: [
createFeature({ timelineProcessed: true }),
createFeature({ matchId: 'KR_2', timelineProcessed: false }),
],
isSeed: false,
puuid: 'target-puuid',
queueId: 420,
});
expect(profile.confidence).toBeCloseTo(0.34);
});
it('aggregates ratio metrics from raw numerator and denominator counts', () => {
const metrics: MetricDefinition[] = [
{