所以我目前正在编写一个程序,可以预测经度和纬度值。到目前为止,我的程序可以预测1个目标值,但我需要预测2个目标值。
column_names = ['longitude', 'Latitude']
raw_dataset = pd.read_csv('loglat.csv', names=column_names)
dataset = raw_dataset.copy()
dataset.tail()
train_dataset = dataset.sample(random_state=0)
test_dataset = dataset.drop(train_dataset.index)
train_labels = train_dataset.pop('longitude')
test_labels = test_dataset.pop('longitude')
normed_train_data = train_dataset
normed_test_data = test_dataset
def build_model():
model = keras.Sequential([
layers.Dense(64, activation=tf.nn.relu, input_shape=[len(train_dataset.keys())]),
layers.Dense(64, activation=tf.nn.relu),
layers.Dense(1)
])
optimizer = tf.keras.optimizers.RMSprop(0.001)
model.compile(loss='mean_squared_error',
optimizer=optimizer,
metrics=['mean_absolute_error', 'mean_squared_error'])
return model
model = build_model()
linreg = model.fit(
normed_train_data, train_labels,
epochs=1000, verbose=0)
test_predictions = model.predict(normed_test_data).flatten()
现在我只能得到经度预测,但是我都想要。 谢谢〜卡佩里先生