Machine Learning - Predict Stock Price - Apple 🍎

화이티 Β·2023λ…„ 12μ›” 20일
0

Machine Learning

λͺ©λ‘ 보기
13/23

https://www.kaggle.com/datasets?search=stock&sort=published

import numpy as np
import pandas as pd
import plotly.graph_objects as go
data = pd.read_csv("./data/stock/apple_stock.csv")
print(data.head())

figure = go.Figure(data=[go.Candlestick(x=data["Date"],
                                        open=data["Open"], high=data["High"],
                                        low=data["Low"], close=data["Close"])])
figure.update_layout(title = "Apple Stock Price Analysis", xaxis_rangeslider_visible=False)
figure.show()

Now let’s move to the task of predicting Apple stock prices. Here I will be using the autots library in Python to predict the stock prices of apple for the next 5 days. If you have never used it before, then you can easily install it, by using the pip command:
(AutoTS is a time series package for Python designed for rapidly deploying high-accuracy forecasts at scale)

pip install autots
from autots import AutoTS

Predict

model = AutoTS(forecast_length=5, frequency='infer', ensemble='simple')
model = model.fit(data, date_col='Date', value_col='Close', id_col=None)
prediction = model.predict()
forecast = prediction.forecast
print(forecast)

profile
μ—΄μ‹¬νžˆ κ³΅λΆ€ν•©μ‹œλ‹€! The best is yet to come! πŸ’œ

0개의 λŒ“κΈ€