-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
31 lines (25 loc) · 1 KB
/
main.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
#!/usr/bin/python
import numpy as np
from sklearn.feature_extraction import DictVectorizer
from pyfm import pylibfm
import pandas as pd
import math
import time
import load
import runFM
import calcMRR
## # import group
## # The users in the test set have been grouped according to user_id so that MRR of every group of users can be calculated.
## # This module has been provided for reference.
## # The test set provided has already been grouped by user_id so it is not necessary to perform this step.
## group.arrange("test_100_10K.txt");
# Loading the training and test datasets
print('Loading data...')
(train_data, y_train, train_users, train_items)=load.loadData("train_final_POP_RND.txt")
(test_data, y_test, test_uers, test_items) = load.loadData("test_final_POP_RND.txt")
# Running Factorization Machine
print('Running FM...')
preds = runFM.FM(train_data, test_data, y_train)
# Evaluation: Calculating the Mean Reciprocal Rank(MRR)
print('Calculating MRR...')
calcMRR.MRR(preds)