recommend/test.py
2024-05-30 12:22:44 -05:00

48 lines
1.2 KiB
Python

from surprise import Dataset, SVD
import numpy as np
import pandas as pd
import sqlite3
from lightfm import LightFM
from lightfm.datasets import fetch_movielens
c = sqlite3.connect("./prisma/dev.db")
df = pd.read_sql_query(
"""
SELECT
s1.user_id as user_id,
s1.beatmap_id as before_beatmap_id,
s2.beatmap_id as after_beatmap_id,
ms_between
FROM Transition as t
JOIN Score as s1 ON s1.id = t.before_id
JOIN Score as s2 ON s2.id = t.after_id
""",
c,
)
print(df)
# Beatmaps with most data:
"""
SELECT
beatmapset_id, artist, title, COUNT(*) as count
FROM Score
JOIN BeatmapSet ON Score.beatmapset_id = BeatmapSet.id
GROUP BY beatmapset_id
ORDER BY count DESC;
"""
# Given a specific beatmap, what maps do they go on to
"""
SELECT
bs1.artist, bs1.title, b1.difficulty, bs2.artist, bs2.title, b2.difficulty, COUNT(*) as count
FROM Transition
JOIN Score as s1 ON s1.id = Transition.before_id
JOIN Score as s2 ON s2.id = Transition.after_id
JOIN Beatmap as b1 on s1.beatmap_id = b1.id
JOIN BeatmapSet as bs1 on s1.beatmapset_id = bs1.id
JOIN Beatmap as b2 on s2.beatmap_id = b2.id
JOIN BeatmapSet as bs2 on s2.beatmapset_id = bs2.id
WHERE s1.beatmapset_id = 320118
GROUP BY s2.beatmap_id
ORDER BY count DESC;
"""