-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetnetflix.py
35 lines (30 loc) · 1.54 KB
/
getnetflix.py
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
from utils.io import save_numpy, load_netflix, save_array
from utils.argcheck import shape, ratio
from providers.split import time_ordered_split
import argparse
from utils.progress import WorkSplitter
def main(args):
progress = WorkSplitter()
progress.section("Load Raw Data")
rating_matrix, timestamp_matrix = load_netflix(path=args.folder, shape=args.shape)
progress.section("Split CSR Matrices")
rtrain, rvalid, rtest, nonzero_index, rtime = time_ordered_split(rating_matrix=rating_matrix,
timestamp_matrix=timestamp_matrix,
ratio=args.ratio, implicit=args.implicit)
progress.section("Save NPZ")
save_numpy(rtrain, args.path, "Rtrain")
save_numpy(rvalid, args.path, "Rvalid")
save_numpy(rtest, args.path, "Rtest")
save_numpy(rtime, args.path, "Rtime")
save_array(nonzero_index, args.path, "Index")
if __name__ == "__main__":
# Commandline arguments
parser = argparse.ArgumentParser(description="Data Preprocess")
parser.add_argument('--implicit', dest='implicit', action='store_true')
parser.add_argument('-r', dest='ratio', type=ratio, default='0.5,0.2,0.3')
parser.add_argument('-f', dest='folder',
default="data/netflix/row/training_set")
parser.add_argument('-d', dest='path', default='data/netflix/')
parser.add_argument('--shape', help="CSR Shape", dest="shape", type=shape, nargs=2)
args = parser.parse_args()
main(args)