Calculating impact of downvotes on reputation: What am I doing wrong?

in #steemdev6 years ago

I am currently attempting to complete an update on the @pibarabot daily flag-war reports. You can measure the weight of a flag in several ways:

  • The impact on projected pay-out as counted in RSHARES
  • The impact on reputation as counted in RSHARES
  • The impact on reputation as counted in reputation points

Basically, I have the first one working OK, and the second one seems ready to use also, only, I would rather use the third one over the second one (together with the first. Today I ran the first test with something that should have done the third, but for some reason, there are some major anomalies.

I'll list a walkthrough.

My script walks through one day of blocks. I start the script every day through cron, and the script processes one single day, seven days in the past. The day that has just closed for downvotes. For this day, I look at all top-level posts (that is, blog posts, not comments) and I fetch the post with its meta data.

Posts of this age still have a lot of useful metadata, including author_reputation and active_votes, the information I was hoping to use for my purpose.

Each vote listed in active_votes has a number of fields, including a timestamp (so I can process them sorted by date) and the reputation of the person casting the vote.

So what do I do to try and calculate the reputation damage done by votes on a post:

def process_content(content,c2):
            rshares = 0.0
            reprshares = int(content["author_reputation"])
            def flagng(voter,reputaton_rshares, vote_rshares):
                def as_rep(rawrep):
                    if rawrep == 0:
                        return 25.0
                    if rawrep > 0:
                        rval = (math.log10(rawrep) - 9)*9+25
                        if rval < 25.0:
                            rval = 25.0
                        return rval
                    else:
                        return 25 - (math.log10(0 - rawrep) - 9)*9
                repdamage = as_rep(reputaton_rshares) - as_rep(reputaton_rshares + vote_rshares)
                print(voter,comment_event["author"],as_rep(reputaton_rshares),as_rep(reputaton_rshares + vote_rshares), "=>", repdamage);
                self.count.flagng(voter,comment_event["author"],repdamage)
            def flag(voter,vote_rshares):
                self.count.flag(voter,comment_event["author"],vote_rshares)
            def downvote(voter,vote_rshares):
                self.count.downvote(voter,comment_event["author"],vote_rshares)
            def flag_or_downvote(voter,vote_rshares,voter_rep):
                if rshares > 0.0:
                    if (vote_rshares > rshares):
                        downvote(voter,rshares)
                    else:
                        downvote(voter,vote_rshares)
                if reprshares < voter_rep:
                    flag(voter, vote_rshares)
                    flagng(voter,reprshares,vote_rshares)
            if len(content["active_votes"]) > 0:
                sortedvotes = sorted(content["active_votes"], key=lambda kv: kv["time"])
                for vote in sortedvotes:
                    if isinstance(vote["rshares"], basestring):
                        vote["rshares"] = float(vote["rshares"])
                    if vote["rshares"] < 0.0:
                        flag_or_downvote(vote["voter"],vote["rshares"],vote["reputation"])
                    rshares += vote["rshares"]
                    reprshares += vote["rshares"]

And everything seemed to be working, but then I looked at some of the actual data for the total link reputation damage:

  1. @spaminator -> @ansie : 230.9
  2. @spaminator -> @tanisa : 169.5
  3. @ipromote -> @liberacesghost : 160.4
  4. @steemcleaners -> @kofpato : 157.3
  5. @steemcleaners -> @dwayne16 : 135.2
  6. @spaminator -> @mamon51 : 122.9
  7. @steemcleaners -> @akbarsanjani : 114.7
  8. @steemcleaners -> @karepo : 110.9
  9. @stellabelle -> @rabiagilani : 107.6
  10. @church-of-piglet -> @subrata9744 : 104.0

Something is definitely terribly wrong here. These accounts might hold quite some punching power, but dealing 230 reputation points of damage to a single account in a single day is simply nonsense. Been looking at my code for over two hours but it just doesn't register. Something is really very wrong about this code, but what is it?

Did I write a silly bug, or am I simply not using the post metadata as it is supposed to be interpreted?

If you are reading this and think you understand what I might be doing horribly wrong, please comment below. I really think adding a by reputation impact visualization to the @pibarabot script would be usefull, but I could really use an other pair of eyes at this point in time.

Sort:  

Do you calculate these points based on the reputation at the end? Reputation is a logarithmic unit, you can't just say something costs 3 points, that is not enough information. 3 points from 25 to 28 are totally different than 3 points from 40 to 43.

Maybe this helps in finding your mistake?

I went over your code only briefly, but I couldn't see the >>6 for the rsahres to the raw reputation - did you include that?
Also keep in mind thatauthor_reputation is the author reputation at any time after the flag, not before... so it includes already the reputation loss due to the flag

I didn't know about the >>6. That explains a lot indeed.
So the author_reputation inside of a post it's metadata isn't the reputation at post-time, or even directly related to the specific post as I assumed? Wow, that complicates things quite a bit it seems.

The >>6 shift is here. It's been a while since I looked into the `author_reputation, so don't quote me on details. IIRC, it is updated on each vote the post receives or author-side edit. Both can be much later than post creation time and represents the state after the corresponding vote.

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 62837.64
ETH 2542.11
USDT 1.00
SBD 2.65