top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

how to calculate reputation in python

0 votes
22 views

I am "confused"..We set the initial value to 0, +1 for up-vote and -1 for down-vote! nice.

I have a list of bool values True, False (True for up vote, False for down-vote).. submitted by users. [True, False, False, True....], Now to calculate the total reputation
should I take True = +1, False=0 [or] True = +1, False=-1 ?? for adding all. I am missing something here.. and thats clear.. anyone please help me on it?

posted Jul 2, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

+1 vote
 
Best answer

It depends what you want to do.

I suggest http://www.evanmiller.org/how-not-to-sort-by-average-rating.html. This aint so simple, but it's the correct way to sort by "approval". In fact, it's bloody confusing.

To assume that only the "sum" approval counts, I'd not suggest {True: 1, False: 0}. The problem is that a "downvote" then becomes pointless. So probably go with False as -1.

So you'd want:
sum((1 if vote else -1) for vote in votes)

answer Jul 2, 2013 by anonymous
+1 vote

You're using False to represent a down-vote and you want down-votes to count as -1, so you would count a False value as -1.

Now why don't you just use 1 and -1 to represent the votes instead of True and False? Then you won't need to worry about this conversion step.

answer Jul 2, 2013 by anonymous
Similar Questions
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...