【发布时间】:2021-05-04 20:48:11
【问题描述】:
首先我想说我是机器学习的新手,所以希望你能帮助我。我想预测股票价格使用机器学习,它适用于我使用 this 教程。为了获得比this更准确,我认为这可能有助于使用更多数据。
现在我有更多包含来自其他股票和其他公司的数据的 CSV 文件,现在我的问题是,我可以使用来自不同股票的文件来获得更准确的数据以及如何强>我能做到吗?
Here is 一个 Stackoverflow 问题描述了我的问题,但答案对我没有帮助。它说在合并后对数据进行规范化。但是我不明白组合数据集有什么意义,因为当我只是将 CSV 文件相互添加时,模型不知道哪些数据是针对哪个 Ticker 的。我希望你能理解我的问题并帮助我。
这是我认为相关的代码:
df = pd.read_csv(r'aapl_data.csv')
df = df[['close']]
# Create variable to predict 'x' days out the future
future_days = 25
# Create a column (target) shifted 'x' days up
df['Prediction'] = df['close'].shift(-future_days)
# Create feature data set, convert it to numpy array and remove last 'x' rows/days
X = np.array(df.drop(['Prediction'], 1))[:-future_days]
# Create target data set (y), convert it to numpy array get all of the target values except the last 'x' rows/days
y = np.array(df['Prediction'])[:-future_days]
# Split the data to 75% training and 25% testing
x_train, x_test, y_train, y_test = train_test_split(X, y, test_size=0.25)
x_train = np.nan_to_num(x_train)
y_train = np.nan_to_num(y_train)
tree = DecisionTreeRegressor().fit(x_train, y_train)
PS:你也会帮助我,在需要时更改标题或告诉我我必须谷歌找到答案,因为我不认为我是第一个有这个想法的人,但我不知道这是怎么回事“问题”被调用。
感谢您的帮助!
【问题讨论】:
标签: python python-3.x machine-learning scikit-learn sklearn-pandas