Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add err scorer #1162

Merged
merged 16 commits into from
Jan 7, 2025
Merged
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions db/scorers/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
let k = 10 // @Rank
// if less than K results, need to reduce K now or final score is too low
k = numReturned() < k ? numReturned() : k
const scores = Array(k);
const missing_rating = 0; // pessimistic assumption
let i = 0
for (i = 0; i < k; i++) {
if (hasDocRating(i)) {
scores[i] = (docRating(i));
} else {
scores[i] = missing_rating;
}
}

function gain(grade, maxGrade=3.0) {
return (Math.pow(2,grade) - 1.0)/Math.pow(2,maxGrade)
}
function err(lst, maxG=3.0) {
let ERR = 0.0
let trust = 1.0
for (i = 0; i < lst.length; i++) {
const rank = i + 1.0
const pUseful = gain(lst[i], maxG)
const disc = pUseful/rank
ERR = ERR + trust * disc
trust = trust * (1.0 - pUseful)
}
return ERR
}
setScore(err(scores))
Loading