Exemplo n.º 1
0
    #dv_dict = getDVDict(coupon_detail_train_file, coupon_list_train_dict.keys())
    dv_dict = {}

    # getting the dict of past coupon purcahse details of user from coupon_detail #
    print "Getting Coupon purchase details.."
    coupon_purchase_detail_dict = getCouponPurchaseDict(
        coupon_detail_feature_file)

    # Getting prefecture location details #
    print "Getting Prefecture location details.. "
    prefecture_location_dict = getPrefectureLocationDict(
        prefecture_location_file)

    # getting coupon area details in form of dict #
    print "Getting coupon area dict.."
    coupon_area_dict = getCouponAreaDict(coupon_area_file)

    # getting coupon visit history of users in form of dict#
    print "Getting the visit history of users.."
    coupon_visit_dict = getCouponVisitDict(coupon_visit_feature_file)

    print "Preparing the data.."
    user_count = 0
    out_row_count = 0
    for user_id in user_dict.keys():
        user_features, user_features_header = getUserFeatures(
            user_dict[user_id], prefecture_location_dict, model_start_date)
        try:
            userid_coupon_purchase_detail_list = coupon_purchase_detail_dict[
                user_id]
        except:
    ## getting the DV Dict of that has purchase combination of userid and coupon id #
    ##print "Getting DV Dict..."
    ##dv_dict = getDVDict(coupon_detail_train_file, coupon_list_train_dict.keys())

    # getting the dict of past coupon purcahse details of user from coupon_detail #
    print "Getting Coupon purchase details.."
    coupon_purchase_detail_dict = getCouponPurchaseDict(coupon_detail_feature_file)

    # Getting prefecture location details #
    print "Getting Prefecture location details.. "
    prefecture_location_dict = getPrefectureLocationDict(prefecture_location_file)

    # getting coupon area details in form of dict #
    print "Getting coupon area dict.."
    coupon_area_dict = getCouponAreaDict(coupon_area_file)

    # getting coupon visit history of users in form of dict#
    print "Getting the visit history of users.."
    coupon_visit_dict = getCouponVisitDict(coupon_visit_feature_file)

    # preparing IDVs #
    print "Preparing IDVs..."
    out_file = csv.writer(open("dev_idvs.csv", "w"))
    random.seed(1234)
    user_count = 0
    out_row_count = 0
    for user_id in coupon_purchase_detail_dict:
        coupon_purchase_detail_userid_list = coupon_purchase_detail_dict[user_id]
        for ind, coupon_dict in enumerate(coupon_purchase_detail_userid_list):
            purchase_coupon = coupon_dict["COUPON_ID_hash"]