Datasets:
Languages:
English
Size:
10K<n<100K
import datasets | |
_CITATION = """\ | |
@InProceedings{huggingface:dataset, | |
title = {Unsplash 25K Photos}, | |
author={James Briggs}, | |
year={2022} | |
} | |
""" | |
_DESCRIPTION = """\ | |
This is a dataset that streams photos data from the Unsplash 25K servers. | |
""" | |
_HOMEPAGE = "https://grouplens.org/datasets/movielens/" | |
_LICENSE = "" | |
_URL = "https://files.grouplens.org/datasets/movielens/ml-25m.zip" | |
class MovieLens(datasets.GeneratorBasedBuilder): | |
"""The MovieLens 25M dataset for ratings""" | |
def _info(self): | |
return datasets.DatasetInfo( | |
description=_DESCRIPTION, | |
features=datasets.Features( | |
{ | |
"imdb_id": datasets.Value("string"), | |
"movie_id": datasets.Value("int32"), | |
"user_id": datasets.Value("int32"), | |
"rating": datasets.Value("float32"), | |
"title": datasets.Value("string"), | |
"year": datasets.Value("int32"), | |
} | |
), | |
supervised_keys=None, | |
homepage="https://grouplens.org/datasets/movielens/", | |
citation=_CITATION, | |
) | |
def _split_generators(self, dl_manager): | |
new_url = dl_manager.download_and_extract(_URL) | |
return [ | |
datasets.SplitGenerator( | |
name=datasets.Split.TRAIN, | |
gen_kwargs={"filepath": new_url+"/photos.tsv000"} | |
), | |
] | |
def _generate_examples(self, filepath): | |
"""This function returns the examples in the raw (text) form.""" | |
with open(filepath, "r") as f: | |
id_ = 0 | |
for line in f: | |
if id_ == 0: | |
cols = line.split("\t") | |
id_ += 1 | |
else: | |
values = line.split("\t") | |
print(id_, {cols[i]: values[i] for i in range(len(cols))}) | |
id_ += 1 | |
if id_ > 5: break |