dibend commited on
Commit
882c412
1 Parent(s): f2567ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -1
app.py CHANGED
@@ -4,6 +4,37 @@ import pandas as pd
4
  from sklearn.linear_model import LinearRegression
5
  import plotly.graph_objects as go
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  def train_predict_wrapper(ticker, start_date, end_date, prediction_days):
8
  # Download asset data
9
  data = yf.download(ticker, start=start_date, end=end_date)
@@ -64,7 +95,8 @@ interface = gr.Interface(
64
  gr.Textbox(label="End Date (YYYY-MM-DD)"),
65
  gr.Slider(minimum=1, maximum=30, step=1, label="Prediction Days"),
66
  ],
67
- outputs="plot"
 
68
  )
69
 
70
  # Launch the app
 
4
  from sklearn.linear_model import LinearRegression
5
  import plotly.graph_objects as go
6
 
7
+ markdown_content = """
8
+ # Asset Price Prediction Tool
9
+
10
+ ## Introduction
11
+ This tool uses historical stock price data to predict future prices. It's designed to provide insights into potential price trends based on past performance.
12
+
13
+ ## How to Use
14
+ 1. **Enter the Ticker Symbol:** Input the stock ticker (e.g., 'AAPL' for Apple Inc.).
15
+ 2. **Select Start and End Dates:** Choose the historical data range for analysis. Dates must be entered in the format YYYY-MM-DD (e.g., 2023-01-01).
16
+ 3. **Set Prediction Days:** Decide how many days into the future you want to predict.
17
+ 4. **Submit:** Click 'Run' to view the predictions.
18
+
19
+ ## How It Works
20
+ - **Data Fetching:** The tool fetches historical closing prices of the specified asset using `yfinance` for the date range you provide.
21
+ - **Model Training:** It then trains a linear regression model on this data. The model learns the relationship between dates and closing prices during this period.
22
+ - **Making Predictions:** Based on the learned relationship, the model attempts to predict future prices for the number of days you specified.
23
+
24
+ ## Understanding Linear Regression
25
+ - Linear regression is a statistical method that models the relationship between a dependent variable and one or more independent variables.
26
+ - In this tool, the dependent variable is the asset's price, and the independent variable is time (dates).
27
+ - The model assumes a linear relationship (a straight line trend) between dates and prices.
28
+ - It's important to note that this method works best when the relationship between the data points is linear and may not capture complex market dynamics.
29
+
30
+ ## Interpreting Data
31
+ - **Historical Prices:** Displayed as a solid blue line, representing actual past closing prices.
32
+ - **Predicted Prices:** Shown as a solid red line, indicating the model's predictions.
33
+ - **Limitations:** The predictions are based on historical trends and do not account for unforeseen market events or changes in market conditions. They should be used as a guideline rather than definitive financial advice.
34
+
35
+ Remember, investing in the stock market involves risks, and past performance is not indicative of future results.
36
+ """
37
+
38
  def train_predict_wrapper(ticker, start_date, end_date, prediction_days):
39
  # Download asset data
40
  data = yf.download(ticker, start=start_date, end=end_date)
 
95
  gr.Textbox(label="End Date (YYYY-MM-DD)"),
96
  gr.Slider(minimum=1, maximum=30, step=1, label="Prediction Days"),
97
  ],
98
+ outputs="plot",
99
+ description=markdown_content
100
  )
101
 
102
  # Launch the app