def setUpClass(cls): cls.n_user_features = 200 cls.n_item_features = 150 cls.interactions, cls.user_features, cls.item_features = generate_dummy_data( num_users=15, num_items=30, interaction_density=.5, num_user_features=cls.n_user_features, num_item_features=cls.n_item_features, n_features_per_user=20, n_features_per_item=20, pos_int_ratio=.5) set_session(None) cls.temp_dir = tempfile.mkdtemp() cls.interactions_path = os.path.join(cls.temp_dir, 'interactions.tfrecord') cls.user_features_path = os.path.join(cls.temp_dir, 'user_features.tfrecord') cls.item_features_path = os.path.join(cls.temp_dir, 'item_features.tfrecord') write_tfrecord_from_sparse_matrix(cls.user_features_path, cls.user_features, get_session()) write_tfrecord_from_sparse_matrix(cls.item_features_path, cls.item_features, get_session()) write_tfrecord_from_sparse_matrix(cls.interactions_path, cls.interactions, get_session())
def setUpClass(cls): # Blow away an existing session to avoid 'tf_map_func not found' error set_session(None) cls.n_users = 15 cls.n_items = 30 int_ds, uf_ds, if_ds = generate_dummy_data(num_users=cls.n_users, num_items=cls.n_items, interaction_density=.5, num_user_features=200, num_item_features=200, n_features_per_user=20, n_features_per_item=20, pos_int_ratio=.5) cls.temp_dir = tempfile.mkdtemp() cls.interactions = os.path.join(cls.temp_dir, 'interactions.tfrecord') cls.user_features = os.path.join(cls.temp_dir, 'user_features.tfrecord') cls.item_features = os.path.join(cls.temp_dir, 'item_features.tfrecord') write_tfrecord_from_sparse_matrix(cls.interactions, int_ds, get_session()) write_tfrecord_from_sparse_matrix(cls.user_features, uf_ds, get_session()) write_tfrecord_from_sparse_matrix(cls.item_features, if_ds, get_session()) cls.standard_model = TensorRec(n_components=10) cls.standard_model.fit(cls.interactions, cls.user_features, cls.item_features, epochs=10) cls.unbiased_model = TensorRec(n_components=10, biased=False) cls.unbiased_model.fit(cls.interactions, cls.user_features, cls.item_features, epochs=10)
def setUpClass(cls): cls.session = get_session()
def setUpClass(cls): cls.session = get_session()