楼主最近在参加一个比赛:比赛链接如下:
https://www.datafountain.cn/competitions/466
现在分享自己的代码,该方案目前成绩在65/2865
运行环境: python 3.7.9,tensorflow 2.0.0,keras 2.3.1
Name:Model_LSTM
一:数据预处理+特征工程
# Version: python 3.7.9 tensorflow 2.0.0 keras 2.3.1
# Name:Model LSTM
import numpy as np
import pandas as pd
import os
import datetime
from tqdm import tqdm
from collections import Counter
import warnings
warnings.filterwarnings("ignore")
def get_info(x):
return [i.split(":")[-1] for i in x.split(" ")]
def get_speed(x):
return np.array([i.split(",")[0] for i in x],dtype='float16')
def get_eta(x):
return np.array([i.split(",")[1] for i in x],dtype="float16")
def get_state(x):
return np.array([i.split(",")[2] for i in x])
def get_cnt(x):
return np.array([i.split(",")[3] for i in x],dtype="int16")
def get_feature(input_file_path_his, input_file_path_attr,input_file_path_topo, mode):
# his
df = pd.read_csv(input_file_path_his, sep=";", header=None)
df["link"] = df[0].apply(lambda x: x.split(" ")[0]).astype(int)
df["label"] = df[0].apply(lambda x: x.split(" ") [1]).astype(int)
df["current_slice_id"] = df[0].apply(lambda x: x.split(" ")[2]).astype(int)
df