刚开始学机器学习写了一个预测雷诺数的程序,但是运行出来误差特别大,自己怎么改都没变化,这到底哪里出问题了,求解答。
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv('D:\雷诺数.csv')
x = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 4].values
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size = 0.2, random_state = 0)
from keras import models
from keras import layers
model = models.Sequential()
model.add(layers.Dense(64,activation='relu',input_shape=(4,)))
model.add(layers.Dense(64,activation='relu'))
model.add(layers.Dense(1))
model.compile(optimizer='adam',
loss='mse',
metrics=['mae'])
x_val = x_train[:400]
partial_x_train = x_train[400:]
y_val = y_train[:400]
partial_y_train = y_train[400:]
history = model.fit(partial_x_train,
partial_y_train,
epochs=6,
batch_size=16,
validation_data=(x_val,y_val))
loss, accuracy = model.evaluate(x_test, y_test)
print('\ntest loss', loss)
print('accuracy', accuracy)
y_pred = model.predict(x_test)
print(y_pred)