be65ce986a45bf2f35b5494db3fa6e993b905aeb,examples/run_din.py,,get_xy_fd,#,7

Before Change




def get_xy_fd():
    feature_dim_dict = {"sparse": [SingleFeat("user", 3), SingleFeat(
        "gender", 2), SingleFeat("item", 3 + 1), SingleFeat("item_gender", 2 + 1)], "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


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

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

    y = [1, 0, 1]
    return x, y, feature_columns, behavior_feature_list
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 12

Instances


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


Project Name: OpenNMT/OpenNMT-py
Commit Name: 522104535e9b0ab4ca4ea8213f4034e1802412f4
Time: 2018-11-02
Author: vince62s@yahoo.com
File Name: onmt/models/model.py
Class Name: NMTModel
Method Name: forward


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