--- title: Interactions Dataset keywords: fastai sidebar: home_sidebar summary: "Implementation of base modules for interactions dataset." description: "Implementation of base modules for interactions dataset." nb_path: "nbs/datasets/bases/datasets.bases.interactions.ipynb" ---
Example:
class ML1mDataset(InteractionsDataset):
url = "http://files.grouplens.org/datasets/movielens/ml-1m.zip"
@property
def raw_file_names(self):
return 'ratings.dat'
def download(self):
path = download_url(self.url, self.raw_dir)
extract_zip(path, self.raw_dir)
from shutil import move, rmtree
move(osp.join(self.raw_dir, 'ml-1m', self.raw_file_names), self.raw_dir)
rmtree(osp.join(self.raw_dir, 'ml-1m'))
os.unlink(path)
def load_ratings_df(self):
df = pd.read_csv(self.raw_paths[0], sep='::', header=None, engine='python')
df.columns = ['uid', 'sid', 'rating', 'timestamp']
# drop duplicate user-item pair records, keeping recent ratings only
df.drop_duplicates(subset=['uid', 'sid'], keep='last', inplace=True)
return df
Example:
class ML1mDataModule(InteractionsDataModule):
dataset_cls = ML1mDataset