如何在TensorFlow中预测航班起飞时间?

时间:2019-05-04 19:39:25

标签: python tensorflow machine-learning keras

我正在制作一个模型,该模型使用星期和月份中的某天来预测航班起飞时间的延迟。每个数据条目的格式为[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0],第一个12位数字表示月份,后7位表示一周中的某天。标签是整数,可以是正数或负数,表示延迟的小时数。

这是我的代码:

#
#
# This model uses day and month as a predictor of delay.
# https://www.kaggle.com/usdot/flight-delays#flights.csv
#
#

# TensorFlow
import tensorflow as tf
from tensorflow import keras
from keras.models import load_model
from keras.models import Sequential
from keras.layers import Dense, Activation
from sklearn.preprocessing import minmax_scale

# Helper libraries
import numpy as np
import csv

# Get features and labels
train_features = np.load("train_features.npy")[:10000, :]
train_labels = np.load("train_labels.npy")[:10000]
print(train_labels)
test_features = np.load("test_features.npy")[:1000, :]
test_labels = np.load("test_labels.npy")[:1000]

# Risk Assessment Model
model = Sequential()
model.add(Dense(6, activation="relu", input_dim=19))
model.add(Dense(1, activation="sigmoid"))

model.compile(optimizer="rmsprop", loss="mean_squared_logarithmic_error", metrics=["accuracy"])

model.fit(
    train_features,
    train_labels,
    epochs=100,
    verbose=1,
    validation_data=(test_features, test_labels),
)

model.save("time_model.h5")

该模型的准确性很差,我很难理解为什么。我不知道我应该使用哪种激活功能,我已经完全迷失了。预先感谢您的帮助。

0 个答案:

没有答案