Verified Commit d5de754b authored by Markus Shepherd's avatar Markus Shepherd 🙊
Browse files

add game names and version with all days

parent 49b22936
Pipeline #453157 passed with stage
in 16 seconds
......@@ -36,31 +36,38 @@ def _compute_scores(
path_dir,
start_date,
end_date,
top=30,
top=None,
):
result = pd.concat(
objs=load_daily_hotness(
path_dir=path_dir, start_date=start_date, end_date=end_date
path_dir=path_dir,
start_date=start_date,
end_date=end_date,
),
axis=1,
)
for bgg_id, ranks in result.T.iteritems():
yield bgg_id, np.exp2(1 - ranks.sort_values().head(top)).mean()
if top:
return pd.Series(
{
bgg_id: np.exp2(1 - ranks.sort_values().head(top)).sum() / top
for bgg_id, ranks in result.T.iteritems()
}
)
full_scores = 2 ** (1 - result)
return full_scores.sum(axis=1) / result.shape[1]
def aggregate_hotness(
path_dir,
start_date,
end_date,
top=30,
top=None,
):
return pd.Series(
dict(
_compute_scores(
path_dir=path_dir,
start_date=start_date,
end_date=end_date,
top=top,
)
)
return _compute_scores(
path_dir=path_dir,
start_date=start_date,
end_date=end_date,
top=top,
).sort_values(ascending=False)
......@@ -15,12 +15,21 @@
# %%
from pathlib import Path
import pandas as pd
from pytility import parse_date
from aggregated_hotness.hotness import aggregate_hotness
# %load_ext nb_black
# %load_ext lab_black
# %%
games = pd.read_csv(
"../../../board-game-data/scraped/bgg_GameItem.csv",
index_col="bgg_id",
low_memory=False,
)
games.shape
# %%
hot_dir = Path("../../../board-game-data/rankings/bgg/hotness/").resolve()
hot_dir
......@@ -31,5 +40,13 @@ aggregated_hotness = aggregate_hotness(
start_date=parse_date("2021-08-01T00:00Z"),
end_date=parse_date("2021-10-01T00:00Z"),
top=30,
).rename("hotness")
aggregated_hotness.shape
# %%
results = (
games[["name"]]
.join(aggregated_hotness, how="right")
.sort_values("hotness", ascending=False)
)
aggregated_hotness.head(50)
results.head(50)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment