示例#1
0
 def gen_rand_user_item_feature(user_num, item_num, class_num):
     user_id = random.randint(1, user_num)
     item_id = random.randint(1, item_num)
     rating = random.randint(1, class_num)
     sample = Sample.from_ndarray(np.array([user_id, item_id]),
                                  np.array([rating]))
     return UserItemFeature(user_id, item_id, sample)
示例#2
0
def to_user_item_feature(row, column_info, model_type="wide_n_deep"):
    """
    convert a row to UserItemFeature given column feature information of a WideAndDeep model

    :param row: Row of userId, itemId, features and label
    :param column_info: ColumnFeatureInfo specify information of different features
    :return: UserItemFeature for recommender model
    """
    return UserItemFeature(row["userId"], row["itemId"],
                           row_to_sample(row, column_info, model_type))
示例#3
0
def to_user_item_feature(row, column_info, model_type="wide_n_deep"):
    return UserItemFeature(row["userId"], row["itemId"],
                           row_to_sample(row, column_info, model_type))
示例#4
0
def build_sample(user_id, item_id, rating):
    sample = Sample.from_ndarray(np.array([user_id, item_id]), np.array([rating]))
    return UserItemFeature(user_id, item_id, sample)