Skip to content

Instantly share code, notes, and snippets.

@calebdre
Created June 14, 2024 00:59
Show Gist options
  • Save calebdre/c9fb70c9cc25f5d513cf76989bca47de to your computer and use it in GitHub Desktop.
Save calebdre/c9fb70c9cc25f5d513cf76989bca47de to your computer and use it in GitHub Desktop.
export const calculateMAPAtK = (
sampleQueries: SampleQuery[],
retrievedResults: QueryResult[][],
k: number
) => {
const apScores = sampleQueries.map((query, index) => {
return calculateAveragePrecision(query, retrievedResults[index], k);
});
return apScores.reduce((sum, score) => sum + score, 0) / apScores.length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment