def test_pagerank_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 pagerank = PageRank() m = pagerank.apply(votes) assert len(m) == 4 for score in m: assert 0.24 < score < 0.26
def test_pagerank(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 pagerank = PageRank() m = pagerank.apply(votes) assert numpy.abs(m[0] - 0.229) < 0.001 assert numpy.abs(m[1] - 0.280) < 0.001 assert numpy.abs(m[2] - 0.267) < 0.001 assert numpy.abs(m[3] - 0.223) < 0.001
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.chart import chart 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),