gpt4 book ai didi

python - ANN 线性回归模型的评估

转载 作者:行者123 更新时间:2023-11-30 09:41:32 30 4
gpt4 key购买 nike

我用 Keras 制作了我的第一个 ANN。它是一个具有 5 个特征和 1 个输出的线性回归模型。我用“MSE”和“损失函数”画了一个图,这些是结果。我们能说它是一个好模型吗?另外 R^2 = 0.91 。这是正确的方法吗?

classifier = Sequential()

classifier.add(Dense(5, input_dim=5,kernel_initializer='normal',activation='relu'))

classifier.add(Dense(5, activation='relu'))

classifier.add(Dense(1,activation='linear'))


classifier.compile(loss='mse', optimizer='adam', metrics=['mse','mae'])

history = classifier.fit(X_train, y_train, batch_size=10, validation_data=(X_test, y_test), epochs=200, verbose=0)

y_pred=classifier.predict(X_test)

train_mse=classifier.evaluate(X_train, y_train, verbose=0)

plt.title('Loss / Mean Squared Error')
plt.plot(history.history['loss'], label='train')
plt.plot(history.history['val_loss'], label='test')
plt.legend()
plt.show()

enter image description here

最佳答案

除了一些术语细节(NN回归不是线性回归,通常我们不会将此类模型称为 classifier ),您的模型看起来确实不错,但有两个错误(训练和测试)减少顺利,没有任何迹象overfitting .

虽然 R^2 值 0.91 听起来不错,但在预测设置中使用该指标(如此处)是相当有问题的;引用我自己的回答 another SO thread :

the whole R-squared concept comes in fact directly from the world of statistics, where the emphasis is on interpretative models, and it has little use in machine learning contexts, where the emphasis is clearly on predictive models; at least AFAIK, and beyond some very introductory courses, I have never (I mean never...) seen a predictive modeling problem where the R-squared is used for any kind of performance assessment; neither it's an accident that popular machine learning introductions, such as Andrew Ng's Machine Learning at Coursera, do not even bother to mention it. And, as noted in the Github thread above (emphasis added):

In particular when using a test set, it's a bit unclear to me what the R^2 means.

我当然同意。

关于python - ANN 线性回归模型的评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58150670/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com