Ejemplo n.º 1
0
def Encoder(target_col, encode_dim=5):
    # data_path = "./"
    # mode和trans_type1,merchant
    if target_col in ['mode']:
        data = op_info
    if target_col in ['trans_typd1', 'merchant']:
        data = trans_info
    keys, matrix = _F.simple_countVectorizer(data, data_path, pri_id,
                                             target_col)
    res = _F.AutoEncoder(matrix, encode_dim)
    temp = pd.DataFrame()
    temp[pri_id] = keys
    for i in range(encode_dim):
        temp[target_col + "_encode_" + str(i)] = res[:, i]
    temp.to_csv(data_path + "data/_F_encode_%s.csv" % target_col, index=False)
    return temp