查看缺失值:
print(f'There are {data_train.isnull().any().sum()} columns in train dataset with missing values.')
漁船軌跡可視化:
def visualize_three_traj():
? ? fig,axes = plt.subplots(nrows=3,ncols=3,figsize=(20,15))
? ? plt.subplots_adjust(wspace=0.2,hspace=0.2)
? ? # 對于每一個類別吩愧,隨機選出刺網(wǎng)的三條軌跡進行可視化
? ? lables = ["ciwang","weiwang","tuowang"]
? ? for i,file_type in tqdm(enumerate(["ciwang_data","weiwang_data","tuowang_data"])):
? ? ? ? data1, data2, data3 = get_random_three_traj(type=file_type)
? ? ? ? for j, datax in enumerate([data1, data2, data3]):
? ? ? ? ? ? x_data = datax["x"].loc[-1:].values
? ? ? ? ? ? y_data = datax["y"].loc[-1:].values
? ? ? ? ? ? axes[i][j - 1].scatter(x_data[0], y_data[0], label="start", c="red", s=10, marker="8")
? ? ? ? ? ? axes[i][j - 1].plot(x_data, y_data, label=lables[i])
? ? ? ? ? ? axes[i][j - 1].scatter(x_data[len(x_data) - 1], y_data[len(y_data) - 1], label="end", c="green", s=10,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? marker="v")
? ? ? ? ? ? axes[i][j - 1].grid(alpha=2)
? ? ? ? ? ? axes[i][j - 1].legend(loc="best")
坐標序列可視化:
def visualize_one_traj_x_y():
? ? fig,axes = plt.subplots(nrows=2,ncols=1,figsize=(10,8))
? ? plt.subplots_adjust(wspace=0.5,hspace=0.5)
? ? data1 = get_random_one_traj(type="weiwang_data")
? ? x = data1["x"].loc[-1:]
? ? x = x / 10000
? ? y = data1["y"].loc[-1:]
? ? y = y / 10000
? ? arr1 = np.arange(len(x))
? ? arr2 = np.arange(len(y))
? ? axes[0].plot(arr1,x,label="x")
? ? axes[1].plot(arr2,y,label="y")
? ? axes[0].grid(alpha=3)
? ? axes[0].legend(loc="best")
? ? axes[1].grid(alpha=3)
? ? axes[1].legend(loc="best")
? ? plt.show()
漁船速度和方向可視化:
def visualize_three_traj_speed_direction():
? ? fig,axes = plt.subplots(nrows=3,ncols=2,figsize=(20,15))
? ? plt.subplots_adjust(wspace=0.3,hspace=0.3)
? ? # 隨機選出刺網(wǎng)的三條軌跡進行可視化
? ? file_types = ["ciwang_data","weiwang_data","tuowang_data"]
? ? speed_types = ["ciwang_speed","weiwang_speed","tuowang_speed"]
? ? doirections = ["ciwang_direction","weiwang_direction","tuowang_direction"]
? ? colors = ['pink', 'lightblue', 'lightgreen']
? ? for i,file_name in tqdm(enumerate(file_types)):
? ? ? ? datax = get_random_one_traj(type=file_name)
? ? ? ? x_data = datax["速度"].loc[-1:].values
? ? ? ? y_data = datax["方向"].loc[-1:].values
? ? ? ? axes[i][0].plot(range(len(x_data)), x_data, label=speed_types[i], color=colors[i])
? ? ? ? axes[i][0].grid(alpha=2)
? ? ? ? axes[i][0].legend(loc="best")
? ? ? ? axes[i][1].plot(range(len(y_data)), y_data, label=doirections[i], color=colors[i])
? ? ? ? axes[i][1].grid(alpha=2)
? ? ? ? axes[i][1].legend(loc="best")
? ? plt.show()