[英]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_MSE和test_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.