【发布时间】:2019-09-16 09:25:25
【问题描述】:
我是机器学习的新手,并尝试使用多种模型(如随机森林、简单线性回归和 NN(LSTM))进行比特币价格预测。
据我所知,随机森林和线性回归不需要输入特征缩放,而 LSTM 确实需要缩放输入特征。
如果我们比较两种算法的 MAE 和 RMSE(有缩放和没有缩放),结果肯定会不同,我无法比较哪个模型的性能更好。
我现在应该如何比较这些模型的性能?
更新 - 添加我的代码
数据
bitcoinData = pd.DataFrame([[('2013-04-01 00:07:00'),93.25,93.30,93.30,93.25,93.300000], [('2013-04-01 00:08:00'),100.00,100.00,100.00,100.00,93.300000], [('2013-04-01 00:09:00'),93.30,93.30,93.30,93.30,33.676862]], columns=['time','open', 'close', 'high','low','volume'])
bitcoinData.time = pd.to_datetime(bitcoinData.time)
bitcoinData = bitcoinData.set_index(['time'])
x_train = train_data[['high','low','open','volume']]
y_train = train_data[['close']]
x_test = test_data[['high','low','open','volume']]
y_test = test_data[['close']]
最小-最大缩放器
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0, 1))
scaler1 = MinMaxScaler(feature_range=(0, 1))
x_train = scaler.fit_transform(x_train)
y_train = scaler1.fit_transform(y_train)
x_test = scaler.transform(x_test)
y_test = scaler1.transform(y_test)
MSE 计算
from math import sqrt
from sklearn.metrics import r2_score
from sklearn.metrics import mean_absolute_error
print("Root Mean Squared Error(RMSE) : ", sqrt(mean_squared_error(y_test,preds)))
print("Mean Absolute Error(MAE) : ", mean_absolute_error(y_test,preds))
r2 = r2_score(y_test, preds)
print("R Squared (R2) : ",r2)
【问题讨论】:
-
请将您的输入数据作为数据而非图像共享。 stackoverflow.com/questions/20109391/…
-
@ItamarMushkin:我已经以数据框的形式更新了输入数据
标签: python machine-learning scikit-learn lstm random-forest