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

Compute p@10 using 0 == irrel, 1+ == rel, so that P@10 is in the expected range [0..1] #991

Merged
merged 7 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
12 changes: 12 additions & 0 deletions db/migrate/20240626181338_reindex_p_at10_code.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ReindexPAt10Code < ActiveRecord::Migration[7.1]
# force existing P@10 scorers to reload using the latest scorer information.
def change
scorers_to_update = ['P@10']
scorers_to_update.each do |scorer_name|
scorer = Scorer.where(name: scorer_name, communal: true).first
name = scorer.name
scorer.code = File.readlines("./db/scorers/#{name.downcase}.js",'\n').join('\n')
scorer.save!
end
end
end
13 changes: 10 additions & 3 deletions db/scorers/p@10.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
var k = 10 // @Rank
var score = avgRating(k);

const k = 10; // @Rank
// k may be > length list, so count up the total number of documents processed.
let count = 0, total = 0;
eachDoc(function(doc, i) {
if (hasDocRating(i) && (docRating(i)) > 0) { // map 0 -> irrel, 1+ ->rel
count = count i+1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
count = count i+1
count = count + 1;

}
total = total + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
total = total + 1
total = total + 1;

}, k);
const score = count / total : 0.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line gives me an error...

setScore(score);