简体   繁体   English

在这两段代码中计算的 mean_squared_error 有什么区别? 我如何比较 metric='mse' 和 mean_squared_error?

[英]what is the difference between the mean_squared_error computed in both of these pieces of code? how can I compare metric='mse' to mean_squared_error?

rf_reg = RandomForestRegressor(
n_estimators=500, 
max_depth=30,                             
criterion="mse",                               
max_features=6,                              
n_jobs=-1,                             
random_state=1)

rf_reg.fit(x_train, y_train)

train_pred_y = rf_reg.predict(x_train)
test_pred_y = rf_reg.predict(x_test)

print(f"train_MSE = {mean_squared_error(y_train, train_pred_y)}")
print(f"test_MSE = {mean_squared_error(y_test, test_pred_y)}")

and

automl.fit(X_train, y_train, task="regression",metric='mse',time_budget=3600)

metric= 'mse' and 'mean_squared_error' are the same "function" (should be kinda aliases, but that's only a guess). metric= 'mse' 和 'mean_squared_error' 是相同的“函数” (应该是别名,但这只是一个猜测)。

The mean_squared_error(y_train, train_pred_y) and the metric='mse' in your .fit() function should print you exactly the same results. .fit( .fit() function 中的mean_squared_error(y_train, train_pred_y)metric='mse'应该打印出完全相同的结果。

What metric='mse' is doing, is just printing you the current model's MSE on the train-dataset your model achieving for each epoch while the training is running. metric='mse'正在做的,只是在训练数据集上打印当前模型的 MSE,你的 model 在训练运行时为每个时期实现。 You could change that to an MAE (mean absolute error) function for example, so you're having a second metric in your training output and not twice the same;)例如,您可以将其更改为 MAE(平均绝对误差)function,因此您在训练中有第二个指标 output 而不是相同的两倍;)

could look similar to this:可能看起来类似于:

Epoch 1/15
108/108 [==============================] - 4s 19ms/step - loss: 0.0173 - mse: 0.0173
Epoch 2/15
108/108 [==============================] - 1s 14ms/step - loss: 0.0143 - mse: 0.0143
...

print(f"train_MSE = {mean_squared_error(y_train, train_pred_y)}") is printing you the MSE again (should be equal to the already printed MSE of the last training epoch). print(f"train_MSE = {mean_squared_error(y_train, train_pred_y)}")再次打印 MSE(应该等于上一个训练时期已经打印的 MSE)。

In the last line the MSE is calculated again but this time the model makes predictions on the test set.在最后一行再次计算 MSE,但这次 model 对测试集进行预测。 Hence the train_MSE and test_MSE should / will differ.因此train_MSEtest_MSE应该/将会不同。

And last but not least criterion="mse" is the loss-function your model is trying to minimize during training;)最后但同样重要的是criterion="mse"是您的 model 在训练期间试图最小化的损失函数;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 张量流中没有提供渐变(mean_squared_error) - No gradients provided in tensorflow (mean_squared_error) 如何在tensorflow会话中使用mean_squared_error损失 - How to use mean_squared_error loss in tensorflow session Tensorflow会话运行不适用于mean_squared_error - Tensorflow session run not working with mean_squared_error sklean mean_squared_error 忽略平方参数, multioutput='raw_values' - sklean mean_squared_error ignores the squared argument, with multioutput='raw_values' 如何评估均方误差(MSE)是否合理? - How do I evaluate whether the mean squared error (MSE) is reasonable or not? 由 TensorFlow 计算的均方误差 - Mean squared error computed by TensorFlow conv_lstm.py示例使用'binary_crossentropy'损失进行回归。 为什么不使用“ mean_squared_error”呢? - conv_lstm.py example uses 'binary_crossentropy' loss for regression. Why not using 'mean_squared_error' instead? ValueError:维度必须相等,但对于 '{{node mean_squared_error/SquaredDifference}} = SquaredDifference[T=DT_FLOAT],维度必须是 68 和 10 - ValueError: Dimensions must be equal, but are 68 and 10 for '{{node mean_squared_error/SquaredDifference}} = SquaredDifference[T=DT_FLOAT] dataframe 中的计算均方误差 (MSE) 问题 - Mean squared error (MSE) problem with calculation in dataframe Numpy 中的均方误差? - Mean Squared Error in Numpy?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM