Spaces:
Sleeping
Sleeping
mistermprah
commited on
Commit
•
926c2a5
1
Parent(s):
1b108a9
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,7 @@ import gradio as gr
|
|
2 |
import numpy as np
|
3 |
import pandas as pd
|
4 |
import yfinance as yf
|
5 |
-
from datetime import datetime
|
6 |
from tensorflow.keras.models import load_model
|
7 |
from joblib import load
|
8 |
|
@@ -109,40 +109,28 @@ def display_historical_data(ticker):
|
|
109 |
return str(e)
|
110 |
|
111 |
# Set up Gradio interface
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
gr.
|
119 |
-
gr.
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
)
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
)
|
133 |
-
|
134 |
-
|
135 |
-
fn=display_historical_data,
|
136 |
-
inputs=[ticker_input],
|
137 |
-
outputs=gr.Dataframe(),
|
138 |
-
title="Historical Data Viewer",
|
139 |
-
description="Select the stock ticker to view the historical data."
|
140 |
-
)
|
141 |
-
|
142 |
-
# Combine interfaces
|
143 |
-
app = gr.TabbedInterface(
|
144 |
-
interface_list=[iface, next_month_iface, historical_data_iface],
|
145 |
-
tab_names=["Predict Today's Price", "Predict Next Month's Price", "View Historical Data"]
|
146 |
-
)
|
147 |
|
148 |
app.launch()
|
|
|
2 |
import numpy as np
|
3 |
import pandas as pd
|
4 |
import yfinance as yf
|
5 |
+
from datetime import datetime
|
6 |
from tensorflow.keras.models import load_model
|
7 |
from joblib import load
|
8 |
|
|
|
109 |
return str(e)
|
110 |
|
111 |
# Set up Gradio interface
|
112 |
+
with gr.Blocks() as app:
|
113 |
+
with gr.Tab("Predict Today's Price"):
|
114 |
+
gr.Markdown("## Predict Today's Price")
|
115 |
+
ticker_input = gr.Dropdown(choices=stock_list, label="Stock Ticker")
|
116 |
+
open_price = gr.Number(label="Open")
|
117 |
+
close_price = gr.Number(label="Close")
|
118 |
+
predict_button = gr.Button("Predict")
|
119 |
+
predict_output = gr.Textbox()
|
120 |
+
predict_button.click(predict_stock_price, inputs=[ticker_input, open_price, close_price], outputs=predict_output)
|
121 |
+
|
122 |
+
with gr.Tab("Predict Next Month's Price"):
|
123 |
+
gr.Markdown("## Predict Next Month's Price")
|
124 |
+
next_month_ticker_input = gr.Dropdown(choices=stock_list, label="Stock Ticker")
|
125 |
+
next_month_predict_button = gr.Button("Predict")
|
126 |
+
next_month_predict_output = gr.Textbox()
|
127 |
+
next_month_predict_button.click(predict_next_month_price, inputs=[next_month_ticker_input], outputs=next_month_predict_output)
|
128 |
+
|
129 |
+
with gr.Tab("View Historical Data"):
|
130 |
+
gr.Markdown("## View Historical Data")
|
131 |
+
historical_ticker_input = gr.Dropdown(choices=stock_list, label="Stock Ticker")
|
132 |
+
historical_view_button = gr.Button("View Data")
|
133 |
+
historical_data_output = gr.Dataframe()
|
134 |
+
historical_view_button.click(display_historical_data, inputs=[historical_ticker_input], outputs=historical_data_output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
app.launch()
|