<commit_before>#!/usr/bin/python

import average_voting
import user_model
import item_model
import graph_builder
import reputation
import numpy as np

N_USERS = 50
N_ITEMS = 50
N_REVIEWS = 5
BIAS_STDEV = 0.2
EVAL_STDEV = 0.2
FRACTION_BAD = 0.15

def eval_quality(values):
    diffs = [values[it] - it.q for it in items]
    return np.std(diffs)

# Builds a graph between users and items.

avs = []
rvs = []
for i in range(10):
    users = [user_model.User(bias_stdev=BIAS_STDEV, eval_stdev=EVAL_STDEV, bimodal=True, frac=FRACTION_BAD)
             for u in range(N_USERS)]
    items = [item_model.Item() for i in range(N_ITEMS)]
    graph = graph_builder.Graph(items, users, reviews=N_REVIEWS)
    # Evaluates this according to simple average. 
    values_via_avg = average_voting.evaluate_items(graph)
    av = eval_quality(values_via_avg)
    print "Via average: ", av
    avs.append(av)
    # Evaluates this according to the reputation system.
    values_via_rep = reputation.evaluate_items(graph)
    rv = eval_quality(values_via_rep)
    print "Via reputation:", rv
    rvs.append(rv)
print "Mean via average:", np.average(avs)
print "Mean via reputation:", np.average(rvs)



<commit_msg>Even more realistic numbers.<commit_after>#!/usr/bin/python

import average_voting
import user_model
import item_model
import graph_builder
import reputation
import numpy as np

N_USERS = 50
N_ITEMS = 50
N_REVIEWS = 5
BIAS_STDEV = 0.2
EVAL_STDEV = 0.1
FRACTION_BAD = 0.15

def eval_quality(values):
    diffs = [values[it] - it.q for it in items]
    return np.std(diffs)

# Builds a graph between users and items.

avs = []
rvs = []
for i in range(10):
    users = [user_model.User(bias_stdev=BIAS_STDEV, eval_stdev=EVAL_STDEV, bimodal=True, frac=FRACTION_BAD)
             for u in range(N_USERS)]
    items = [item_model.Item() for i in range(N_ITEMS)]
    graph = graph_builder.Graph(items, users, reviews=N_REVIEWS)
    # Evaluates this according to simple average. 
    values_via_avg = average_voting.evaluate_items(graph)
    av = eval_quality(values_via_avg)
    print "Via average: ", av
    avs.append(av)
    # Evaluates this according to the reputation system.
    values_via_rep = reputation.evaluate_items(graph)
    rv = eval_quality(values_via_rep)
    print "Via reputation:", rv
    rvs.append(rv)
print "Mean via average:", np.average(avs)
print "Mean via reputation:", np.average(rvs)




{'fraction_non_alphanumeric': 0.09779442363712026, 'fraction_numerical': 0.011652101539741989, 'mean_word_length': 4.018789144050104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4897868', 'n_tokens_mistral': 896, 'n_tokens_neox': 850, 'n_words': 225}