forked from nikke-rookie/PAMCL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSELFRec.py
More file actions
35 lines (27 loc) · 1.35 KB
/
SELFRec.py
File metadata and controls
35 lines (27 loc) · 1.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
from data.loader import FileIO
from time import strftime, localtime, time
class SELFRec(object):
def __init__(self, config):
self.social_data = []
self.feature_data = []
self.config = config
print('Reading data and preprocessing...')
self.training_data = FileIO.load_data_set(config['training.set'])
self.test_data = FileIO.load_data_set(config['test.set'])
self.kwargs = {}
self.kwargs['timestamp'] = strftime("%Y-%m-%d %H-%M-%S", localtime(time()))
self.kwargs['model_name'] = config['model']['name']
if config.contain('image_modal') and config['image_modal']['fusion']:
self.kwargs['image_modal'] = config['image_modal']
if config.contain('text_modal') and config['text_modal']['fusion']:
self.kwargs['text_modal'] = config['text_modal']
if config.contain('user_pref') and config['user_pref']['fusion']:
self.kwargs['user_pref'] = config['user_pref']
def execute(self, is_eval=False):
import_str = f"from {self.config['model']['name']} import {self.config['model']['name']}"
exec(import_str)
recommender = f"{self.config['model']['name']}(self.config,self.training_data,self.test_data,**self.kwargs)"
if is_eval:
eval(recommender).eval()
else:
eval(recommender).execute()