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

标签 python machine-learning keras neural-network regression

我用 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/

相关文章:

python - Pandas 插值后剩余的 NaN

python - matplotlib:为条形分配不同的影线

machine-learning - APPLY_KMEANS 在 Vertica 中如何工作

python - 自定义 Keras 指标返回 'axis out of bounds' 错误

python - 实验确定矩阵行列式的计算复杂度

python - 如何设置flask github.authorized处理程序收到的 "next"url?

machine-learning - 从公开可用的词嵌入中提取更有意义的词

python - 在 tensorflow 中创建一个 float64 变量

python - Keras 顺序模型损失不会减少并且在所有时期都保持不变

python - 为什么当作为参数传递给 `input_shape` 层时, `Dense` 不包括批处理维度?