Last active
March 11, 2023 19:40
-
-
Save LouisdeBruijn/f77a5a51dbb3251881f66ca0f7632755 to your computer and use it in GitHub Desktop.
Load MovieLens 1m dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import pandas as pd | |
import numpy as np | |
from scipy.sparse import csr_matrix, save_npz, load_npz, vstack, hstack, lil_matrix | |
import implicit | |
import pickle | |
from implicit.evaluation import train_test_split, precision_at_k, mean_average_precision_at_k | |
def load_data(): | |
'''load the MovieLens 1m dataset in a Pandas dataframe''' | |
ratings = pd.read_csv('ml-1m/ratings.dat', delimiter='::', header=None, | |
names=['user_id', 'movie_id', 'rating', 'timestamp'], | |
usecols=['user_id', 'movie_id', 'rating'], engine='python') | |
return ratings | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It works, thanks