我已经符合方程式了。现在我需要RMSE值
q3_1=data1[['bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors', 'zipcode']]
q3_2=data1[['bedrooms', 'bathrooms', 'sqft_living', 'sqft_lot', 'floors','zipcode','condition','grade','waterfront','view','sqft_above','sqft_basement','yr_built','yr_renovated',
'lat', 'long','sqft_living15','sqft_lot15']]
reg = LinearRegression()
reg.fit(q3_1,data1.price)
reg.fit(q3_2,data1.price)我不能从这里开始。我需要这两种情况下的RMSE值。
发布于 2019-11-18 22:30:26
据我所知,你在谷歌Colab上使用TensorFlow。
我不知道你的LinearRegression对象到底是什么,但我假设它是一个只有一个节点的Keras模型。
因此,我有一个问题,如何用具有不同模式的datasets训练相同的模型( reg实例) --一个有6列,另一个有16列?
顺便说一句,在训练/拟合过程中,keras能够给你提供你所在时代的MSE,如果你提供了一个验证数据集,还可以提供一个验证MSE。最后,您可以使用evaluate方法,该方法:
返回模型的损失值和度量值...
只需使用"mean_squared_error“指标即可。
编辑
当您使用scikit-learn时,您必须自己处理指标。您可以使用predict方法从经过训练的模型中获得针对数据集的预测。然后是mean_squared_error指标,它使用起来很简单。
train_x, train_y = data1.features[:-100], data1.price[:-100]
test_x, test_y = data1.features[-100:], data1.price[-100:]
reg = LinearRegression()
reg.fit(train_x, train_y)
predictions = reg.predict(test_x)
mse = sklearn.metrics.mean_squared_error(test_y, predictions)
print("RMSE: %s" % math.sqrt(mse))https://stackoverflow.com/questions/58916506
复制相似问题