be65ce986a45bf2f35b5494db3fa6e993b905aeb,tests/models/DIN_test.py,,get_xy_fd,#Any#,9

Before Change




def get_xy_fd(hash_flag=False):
    feature_dim_dict = {"sparse": [SingleFeat("user", 3, hash_flag), SingleFeat(
        "gender", 2, hash_flag), SingleFeat("item", 3 + 1, hash_flag), SingleFeat("item_gender", 2 + 1, hash_flag)],
                        "dense": [SingleFeat("score", 0)]}
    behavior_feature_list = ["item", "item_gender"]
    uid = np.array([0, 1, 2])
    ugender = np.array([0, 1, 0])
    iid = np.array([1, 2, 3])  // 0 is mask value
    igender = np.array([1, 2, 1])  // 0 is mask value
    score = np.array([0.1, 0.2, 0.3])

    hist_iid = np.array([[1, 2, 3, 0], [1, 2, 3, 0], [1, 2, 0, 0]])
    hist_igender = np.array([[1, 1, 2, 0], [2, 1, 1, 0], [2, 1, 0, 0]])

    feature_dict = {"user": uid, "gender": ugender, "item": iid, "item_gender": igender,
                    "hist_item": hist_iid, "hist_item_gender": hist_igender, "score": score}

    x = [feature_dict[feat.name] for feat in feature_dim_dict["sparse"]] + [feature_dict[feat.name] for feat in
                                                                            feature_dim_dict["dense"]] + [
            feature_dict["hist_" + feat] for feat in behavior_feature_list]

    y = [1, 0, 1]
    return x, y, feature_dim_dict, behavior_feature_list

After Change


    //     "gender", 2, hash_flag), SingleFeat("item", 3 + 1, hash_flag), SingleFeat("item_gender", 2 + 1, hash_flag)],
    //                     "dense": [SingleFeat("score", 0)]}

    feature_columns = [SparseFeat("user",3),SparseFeat(
        "gender", 2), SparseFeat("item", 3 + 1), SparseFeat("item_gender", 2 + 1),DenseFeat("score", 0)]
    feature_columns += [VarLenSparseFeat("hist_item",3+1, maxlen=4, embedding_name="item"),
                        VarLenSparseFeat("hist_item_gender",3+1, maxlen=4, embedding_name="item_gender")]

    behavior_feature_list = ["item", "item_gender"]
    uid = np.array([0, 1, 2])
    ugender = np.array([0, 1, 0])
    iid = np.array([1, 2, 3])  // 0 is mask value
    igender = np.array([1, 2, 1])  // 0 is mask value
    score = np.array([0.1, 0.2, 0.3])

    hist_iid = np.array([[1, 2, 3, 0], [1, 2, 3, 0], [1, 2, 0, 0]])
    hist_igender = np.array([[1, 1, 2, 0], [2, 1, 1, 0], [2, 1, 0, 0]])

    feature_dict = {"user": uid, "gender": ugender, "item": iid, "item_gender": igender,
                    "hist_item": hist_iid, "hist_item_gender": hist_igender, "score": score}

    feature_names = get_fixlen_feature_names(feature_columns)
    varlen_feature_names = get_varlen_feature_names(feature_columns)
    x = [feature_dict[name] for name in feature_names] + [feature_dict[name] for name in varlen_feature_names]


    // x = [feature_dict[feat.name] for feat in feature_dim_dict["sparse"]] + [feature_dict[feat.name] for feat in
    //                                                                         feature_dim_dict["dense"]] + [
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 21

Instances


Project Name: shenweichen/DeepCTR
Commit Name: be65ce986a45bf2f35b5494db3fa6e993b905aeb
Time: 2019-06-30
Author: wcshen1994@163.com
File Name: tests/models/DIN_test.py
Class Name:
Method Name: get_xy_fd


Project Name: bokeh/bokeh
Commit Name: ef90233e8a378c3049cb6955ba88f6598dc545d0
Time: 2015-12-22
Author: bryanv@continuum.io
File Name: examples/plotting/file/texas.py
Class Name:
Method Name:


Project Name: shenweichen/DeepCTR
Commit Name: be65ce986a45bf2f35b5494db3fa6e993b905aeb
Time: 2019-06-30
Author: wcshen1994@163.com
File Name: examples/run_din.py
Class Name:
Method Name: get_xy_fd