def test_eigentrust_trivial(self): votes = VoteMatrix(4) votes.positive[0, 1] = 1 votes.positive[1, 2] = 1 votes.positive[2, 3] = 1 votes.positive[3, 0] = 1 eigentrust = EigenTrust() m = eigentrust.apply(votes) assert len(m) == 4 for score in m: assert score == 0.25
def test_eigentrust(self): votes = VoteMatrix(4) votes.positive[0, 1] = 1 votes.positive[0, 2] = 1 votes.positive[2, 1] = 1 votes.positive[3, 0] = 1 votes.positive[3, 2] = 4 eigentrust = EigenTrust(lambda x: la.norm(x, numpy.inf)) m = eigentrust.apply(votes) assert numpy.abs(m[0] - 0.139) < 0.01 assert numpy.abs(m[1] - 0.465) < 0.01 assert numpy.abs(m[2] - 0.279) < 0.01 assert numpy.abs(m[3] - 0.117) < 0.01
from output.metrics import print_metrics, print_stddev_metrics from simulation.community import ActionProfile from simulation.member import Member if __name__ == '__main__': """ In this test, it is evaluated how many friends who are significantly less competent than their peers are required to trick the system so that they reach top position in the reputation ranking. """ test_name = "Friends" community = OnlineDiscussionGroup() ALL_CENTRALITY_SCORES = [ PageRank(), EigenTrust(), InDegree(), InDegreePositive() ] # Possible Actions actions: ActionProfile = community.action_profile # Group unaffiliated num_unaffiliated = 25 unaffiliated = Member("unaffiliated", [ (0.27, actions.post_good_comment), (0.03, actions.post_bad_comment), (0.32, actions.vote_bad_comment_negative), (0.03, actions.vote_any_comment_negative), (0.32, actions.vote_good_comment_positive),
from output.metrics import print_metrics, print_stddev_metrics from simulation.member import Member if __name__ == '__main__': """ The more basic tests are concluded with the Productivity Test, which investigates what kind of effect different levels of productivity, all other parameters being equal, have on the reputation score. """ test_name = "Productivity-high" community = OnlineDiscussionGroup() ALL_CENTRALITY_SCORES = [ PageRank(), EigenTrust(), InDegree(), InDegreePositive() ] # Possible Actions actions = community.action_profile # Group low low_student = Member("low", [ (0.19, actions.post_good_comment), (0.01, actions.post_bad_comment), (0.38, actions.vote_bad_comment_negative), (0.02, actions.vote_any_comment_negative), (0.38, actions.vote_good_comment_positive), (0.02, actions.vote_any_comment_positive),