def build_mlp(user_num, item_num): input = Input(shape=[2]) user_emb_mlp = LatentFactorMapper(feat_column_id=0, id_num=user_num, embedding_dim=64)(input) item_emb_mlp = LatentFactorMapper(feat_column_id=1, id_num=user_num, embedding_dim=64)(input) output = MLPInteraction()([user_emb_mlp, item_emb_mlp]) output = RatingPredictionOptimizer()(output) model = RPRecommender(inputs=input, outputs=output) return model
def build_gmf(user_num, item_num): input = Input(shape=[2]) user_emb = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) output = InnerProductInteraction()([user_emb, item_emb]) output = RatingPredictionOptimizer()(output) model = RPRecommender(inputs=input, outputs=output) return model
def build_gmf(user_num, item_num): input = Input(shape=[2]) user_emb = LatentFactorMapper(feat_column_id=0, id_num=user_num, embedding_dim=64)(input) item_emb = LatentFactorMapper(feat_column_id=1, id_num=item_num, embedding_dim=64)(input) output = ElementwiseInteraction(elementwise_type="innerporduct")( [user_emb, item_emb]) output = RatingPredictionOptimizer()(output) model = RPRecommender(inputs=input, outputs=output) return model
def build_autorec(user_num, item_num): input = Input(shape=[2]) user_emb_1 = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb_1 = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) user_emb_2 = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb_2 = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) output = HyperInteraction()( [user_emb_1, item_emb_1, user_emb_2, item_emb_2]) output = RatingPredictionOptimizer()(output) model = RPRecommender(inputs=input, outputs=output) return model
def build_neumf(user_num, item_num): input = Input(shape=[2]) user_emb_gmf = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb_gmf = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) innerproduct_output = InnerProductInteraction()( [user_emb_gmf, item_emb_gmf]) user_emb_mlp = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb_mlp = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) mlp_output = MLPInteraction()([user_emb_mlp, item_emb_mlp]) output = RatingPredictionOptimizer()([innerproduct_output, mlp_output]) model = RPRecommender(inputs=input, outputs=output) return model
num_of_entities=item_num, embedding_dim=64)(input) user_emb_mlp = LatentFactorMapper(column_id=0, num_of_entities=user_num, embedding_dim=64)(input) item_emb_mlp = LatentFactorMapper(column_id=1, num_of_entities=item_num, embedding_dim=64)(input) # Step 2.2: Setup interactors to handle models innerproduct_output = InnerProductInteraction()([user_emb_gmf, item_emb_gmf]) mlp_output = MLPInteraction()([user_emb_mlp, item_emb_mlp]) # Step 2.3: Setup optimizer to handle the target task output = RatingPredictionOptimizer()([innerproduct_output, mlp_output]) model = RPRecommender(inputs=input, outputs=output) # Step 3: Build the searcher, which provides search algorithm searcher = Search(model=model, tuner='greedy', # random, greedy tuner_params={"max_trials": 5, 'overwrite': True} ) # Step 4: Use the searcher to search the recommender searcher.search(x=[train_X_categorical], y=train_y, x_val=[val_X_categorical], y_val=val_y, objective='val_mse', batch_size=1024, epochs=1,