Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
chore: debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Dec 24, 2023
1 parent be720dd commit cbacaa2
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions src/handlers/issue/relevance-scoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,27 @@ function filterSamples(batchResults: number[][], correctLength: number) {
}

function averageSamples(batchResults: (number | Decimal)[][], precision: number) {
const averageScores = batchResults[0]
.map((_, columnIndex) => {
let sum = new Decimal(0);
batchResults.forEach((row) => {
sum = sum.plus(row[columnIndex]);
});
return sum.dividedBy(batchResults.length);
})
.map((score) => score.toDecimalPlaces(precision));

return averageScores;
try {
return batchResults[0]
.map((_, columnIndex) => {
let sum = new Decimal(0);
batchResults.forEach((row) => {
sum = sum.plus(row[columnIndex]);
});
return sum.dividedBy(batchResults.length);
})
.map((score) => score.toDecimalPlaces(precision));
} catch (error) {
console.error("Failed to average samples", { error });
console.trace({ batchResults });
return batchResults
.map((_, columnIndex) => {
let sum = new Decimal(0);
batchResults.forEach((row) => {
sum = sum.plus(row[columnIndex]);
});
return sum.dividedBy(batchResults.length);
})
.map((score) => score.toDecimalPlaces(precision));
}
}

0 comments on commit cbacaa2

Please sign in to comment.