Repository navigation
Expand file tree
/
Copy pathload_movielens.py
More file actions
56 lines (51 loc) · 2.35 KB
/
Copy pathload_movielens.py
File metadata and controls
56 lines (51 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
from popcorn.utils import readConfigs
from popcorn.datasets.movielens.loader import loadMovieLens
from popcorn.datasets.utils import printTextualDatasetStats
def main():
print(
"Welcome to 'Popcorn' 🍿! Starting the framework for your movie recommendation ...\n"
)
# Read the configuration file
configs = readConfigs("popcorn/config/config.yml")
# If properly read, print the configurations
if not configs:
print("Error reading the configuration file!")
return
# Load MovieLens dataset - 100k version
print("\n----------- MovieLens 100k -----------")
configs["datasets"]["unimodal"]["movielens"]["version"] = "100k"
itemsDF, usersDF, ratingsDF, linksDF = loadMovieLens(configs)
if itemsDF is not None:
print(f"\n- ItemsDF (shape: {itemsDF.shape}): \n{itemsDF.head()}")
if usersDF is not None:
print(f"\n- UsersDF (shape: {usersDF.shape}): \n{usersDF.head()}")
if ratingsDF is not None:
print(f"\n- RatingsDF (shape: {ratingsDF.shape}): \n{ratingsDF.head()}\n")
printTextualDatasetStats(ratingsDF)
# Load MovieLens dataset - 1m version
print("\n----------- MovieLens 1m -----------")
configs["datasets"]["unimodal"]["movielens"]["version"] = "1m"
itemsDF, usersDF, ratingsDF, linksDF = loadMovieLens(configs)
if itemsDF is not None:
print(f"\n- ItemsDF (shape: {itemsDF.shape}): \n{itemsDF.head()}")
if usersDF is not None:
print(f"\n- UsersDF (shape: {usersDF.shape}): \n{usersDF.head()}")
if ratingsDF is not None:
print(f"\n- RatingsDF (shape: {ratingsDF.shape}): \n{ratingsDF.head()}\n")
printTextualDatasetStats(ratingsDF)
# Load MovieLens dataset - 25m version
print("\n----------- MovieLens 25m -----------")
configs["datasets"]["unimodal"]["movielens"]["version"] = "25m"
itemsDF, usersDF, ratingsDF, linksDF = loadMovieLens(configs)
if itemsDF is not None:
print(f"\n- ItemsDF (shape: {itemsDF.shape}): \n{itemsDF.head()}")
if usersDF is not None:
print(f"\n- UsersDF (shape: {usersDF.shape}): \n{usersDF.head()}")
if ratingsDF is not None:
print(f"\n- RatingsDF (shape: {ratingsDF.shape}): \n{ratingsDF.head()}\n")
printTextualDatasetStats(ratingsDF)
# Stop
print("\nStopping 'Popcorn'!")
if __name__ == "__main__":
main()