Esempio n. 1
0
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib.ticker import NullFormatter
from matplotlib import lines

import numpy as np
import angrymetalpy as amp

if __name__ == '__main__':
    reviews = amp.reviews_from_json('data_20180422.txt')
    print(len(reviews))
    min_date, max_date = amp.date_range(reviews)
    num_months = amp.months_between(min_date, max_date) + 1

    scores = np.zeros(num_months)
    counts = np.zeros(num_months)
    perfect_albums = [[] for _ in range(num_months)]

    for rev in reviews:
        idx = amp.months_between(min_date, rev.date)
        scores[idx] += rev.score
        counts[idx] += 1
        if rev.score == 5.0:
            perfect_albums[idx].append(rev.album)

    scores /= counts  # average scores per month
    score_unc = np.sqrt(counts) / counts

    fig = plt.figure(figsize=(5, 4), dpi=100)
    rect = (1, 1, 1, 1)
    #ax2 = fig.add_axes(rect, label='axis2')
Esempio n. 2
0
import matplotlib.pyplot as plt

import numpy as np
import angrymetalpy as amp

if __name__ == '__main__':
    reviews = amp.reviews_from_json('data_20180422.txt')
    amg_reviewers = amp.reviewers_from_reviews(reviews)

    amg_reviewers = sorted(amg_reviewers, key=lambda x: len(x.reviews))

    fig = plt.figure(figsize=(5, 8), dpi=100)
    ax = fig.add_subplot(111)

    min_date, max_date = amp.date_range(reviews)
    n_months = amp.months_between(min_date, max_date)

    # timeline of reviewer activity
    xs = []
    ys = []
    for i, reviewer in enumerate(amg_reviewers):
        for review in reviewer.reviews:
            xs.append(amp.months_between(min_date, review.date))
            ys.append(i)

    xbins = np.arange(0, n_months + 1, 1)
    ybins = np.arange(0, len(amg_reviewers) + 1, 1)
    ax.hist2d(xs, ys, bins=[xbins, ybins])
    ax.set_ylim(0, len(amg_reviewers) - 0.5)

    # y axis should line up reviewer names with rows
Esempio n. 3
0
import matplotlib.pyplot as plt

import numpy as np
import angrymetalpy as amp

if __name__ == '__main__':
    reviews = amp.reviews_from_json('data_20180422.txt')
    amg_reviewers = amp.reviewers_from_reviews(reviews)

    amg_reviewers = sorted(amg_reviewers, key=lambda x: len(x.reviews))

    fig = plt.figure()
    ax = fig.add_subplot(111)

    min_date, max_date = amp.date_range(reviews)
    n_months = amp.months_between(min_date, max_date)

    xs = np.arange(start=0, stop=n_months, step=1)
    # timeline of reviewer activity
    for i, reviewer in enumerate(amg_reviewers):
        ys = np.zeros(n_months)
        ys_counts = np.zeros(n_months)
        for review in reviewer.reviews:
            idx = amp.months_between(min_date, review.date)
            ys[idx - 1] += review.score
            ys_counts[idx - 1] += 1

        idxs = np.where(ys_counts > 3)
        ys[idxs] /= ys_counts[idxs]

        if len(idxs[0]) > 1:
Esempio n. 4
0
import datetime as dt

import numpy as np
import matplotlib.pyplot as plt

import angrymetalpy as amp

if __name__ == '__main__':
    reviews = amp.reviews_from_json('data_20180422.txt')
    min_date, max_date = amp.date_range(reviews)
    num_months = amp.months_between(min_date, max_date) + 1

    sc = []
    sc_past = []
    six_months_ago = dt.datetime.today() - dt.timedelta(6*365/12)

    for rev in reviews:
        sc.append(rev.score)
        if rev.date > six_months_ago:
            sc_past.append(rev.score)

    print(np.mean(sc), np.median(sc))
    fig_hist = plt.figure(figsize=(5,4), dpi=100)
    axhist = fig_hist.add_subplot(111)
    axhist.hist(sc, bins=np.arange(0, 6, step=0.5))
    axhist.set_ylabel('Counts')
    axhist.set_xlabel('Score')
    axhist.set_xlim(0, 5.25)
    axhist.set_title('All Scores')
    xtickpos = 0.25 + np.arange(0, 6, step=0.5)
    plt.xticks(xtickpos, np.arange(0, 6, step=0.5))