Spaces:
Runtime error
Runtime error
changed default values
Browse files- pages/3_📊_Make_a_Model.py +12 -9
pages/3_📊_Make_a_Model.py
CHANGED
@@ -5,7 +5,7 @@ import yfinance as yf
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import numpy as np
|
7 |
import plotly.express as px
|
8 |
-
import time
|
9 |
from statsmodels.tsa.arima_model import ARIMA
|
10 |
from sklearn.metrics import mean_absolute_percentage_error, mean_squared_error, mean_absolute_error
|
11 |
import tensorflow as tf
|
@@ -26,11 +26,13 @@ footer{visibility:hidden;}
|
|
26 |
</style>
|
27 |
"""
|
28 |
# page expands to full width
|
29 |
-
st.set_page_config(page_title="Predicta.oil | Make a Model",
|
|
|
30 |
st.markdown(hide_menu_style, unsafe_allow_html=True)
|
31 |
# ag grid pagination
|
32 |
add_logo()
|
33 |
|
|
|
34 |
def pagination(df):
|
35 |
gb = GridOptionsBuilder.from_dataframe(df)
|
36 |
gb.configure_pagination(paginationAutoPageSize=True)
|
@@ -42,8 +44,8 @@ def pagination(df):
|
|
42 |
st.title("Make a Model")
|
43 |
|
44 |
# ARIMA PARAMETERS
|
45 |
-
pValue =
|
46 |
-
dValue =
|
47 |
qValue = 0
|
48 |
|
49 |
# show raw data
|
@@ -53,7 +55,7 @@ st.header("Raw Data")
|
|
53 |
with st.sidebar.header('Set Data Split'):
|
54 |
# PARAMETERS min,max,default,skip
|
55 |
trainData = st.sidebar.slider(
|
56 |
-
'Data split ratio (% for Training Set)', 10, 90,
|
57 |
# ARIMA PARAMETERS
|
58 |
pValue = st.sidebar.number_input('P-value:', 0, 100, pValue)
|
59 |
st.sidebar.write('The current p-Value is ', pValue)
|
@@ -67,7 +69,7 @@ with st.sidebar.header('Set Data Split'):
|
|
67 |
|
68 |
# select time interval
|
69 |
interv = st.select_slider('Select Time Series Data Interval for Prediction', options=[
|
70 |
-
'Weekly', 'Monthly', 'Quarterly', '
|
71 |
|
72 |
|
73 |
@st.cache
|
@@ -102,7 +104,6 @@ st.download_button(
|
|
102 |
)
|
103 |
|
104 |
|
105 |
-
|
106 |
# graph visualization
|
107 |
st.header("Visualizations")
|
108 |
|
@@ -128,6 +129,7 @@ def mse_eval(test, predictions):
|
|
128 |
def mape_eval(test, predictions):
|
129 |
return mean_absolute_percentage_error(test, predictions)
|
130 |
|
|
|
131 |
def evaluate_lstm_model(split):
|
132 |
global lstmModel
|
133 |
WINDOW_SIZE = 3
|
@@ -138,8 +140,7 @@ def evaluate_lstm_model(split):
|
|
138 |
df.shape[0]*split)], df.index[int(df.shape[0]*split)+WINDOW_SIZE:]
|
139 |
X_train1, y_train1 = X1[:int(df.shape[0]*split)
|
140 |
], y1[:int(df.shape[0]*split)]
|
141 |
-
X_test1, y_test1 = X1[int(df.shape[0]*split)
|
142 |
-
:], y1[int(df.shape[0]*split):]
|
143 |
|
144 |
# lstm model
|
145 |
with st.spinner('LSTM Model...'):
|
@@ -172,6 +173,8 @@ def evaluate_lstm_model(split):
|
|
172 |
print(mape)
|
173 |
|
174 |
return test_results, mse, mape
|
|
|
|
|
175 |
global results
|
176 |
|
177 |
|
|
|
5 |
import matplotlib.pyplot as plt
|
6 |
import numpy as np
|
7 |
import plotly.express as px
|
8 |
+
import time
|
9 |
from statsmodels.tsa.arima_model import ARIMA
|
10 |
from sklearn.metrics import mean_absolute_percentage_error, mean_squared_error, mean_absolute_error
|
11 |
import tensorflow as tf
|
|
|
26 |
</style>
|
27 |
"""
|
28 |
# page expands to full width
|
29 |
+
st.set_page_config(page_title="Predicta.oil | Make a Model",
|
30 |
+
layout='wide', page_icon="⛽")
|
31 |
st.markdown(hide_menu_style, unsafe_allow_html=True)
|
32 |
# ag grid pagination
|
33 |
add_logo()
|
34 |
|
35 |
+
|
36 |
def pagination(df):
|
37 |
gb = GridOptionsBuilder.from_dataframe(df)
|
38 |
gb.configure_pagination(paginationAutoPageSize=True)
|
|
|
44 |
st.title("Make a Model")
|
45 |
|
46 |
# ARIMA PARAMETERS
|
47 |
+
pValue = 1
|
48 |
+
dValue = 0
|
49 |
qValue = 0
|
50 |
|
51 |
# show raw data
|
|
|
55 |
with st.sidebar.header('Set Data Split'):
|
56 |
# PARAMETERS min,max,default,skip
|
57 |
trainData = st.sidebar.slider(
|
58 |
+
'Data split ratio (% for Training Set)', 10, 90, 50, 5)
|
59 |
# ARIMA PARAMETERS
|
60 |
pValue = st.sidebar.number_input('P-value:', 0, 100, pValue)
|
61 |
st.sidebar.write('The current p-Value is ', pValue)
|
|
|
69 |
|
70 |
# select time interval
|
71 |
interv = st.select_slider('Select Time Series Data Interval for Prediction', options=[
|
72 |
+
'Daily', 'Weekly', 'Monthly', 'Quarterly'], value='Weekly')
|
73 |
|
74 |
|
75 |
@st.cache
|
|
|
104 |
)
|
105 |
|
106 |
|
|
|
107 |
# graph visualization
|
108 |
st.header("Visualizations")
|
109 |
|
|
|
129 |
def mape_eval(test, predictions):
|
130 |
return mean_absolute_percentage_error(test, predictions)
|
131 |
|
132 |
+
|
133 |
def evaluate_lstm_model(split):
|
134 |
global lstmModel
|
135 |
WINDOW_SIZE = 3
|
|
|
140 |
df.shape[0]*split)], df.index[int(df.shape[0]*split)+WINDOW_SIZE:]
|
141 |
X_train1, y_train1 = X1[:int(df.shape[0]*split)
|
142 |
], y1[:int(df.shape[0]*split)]
|
143 |
+
X_test1, y_test1 = X1[int(df.shape[0]*split):], y1[int(df.shape[0]*split):]
|
|
|
144 |
|
145 |
# lstm model
|
146 |
with st.spinner('LSTM Model...'):
|
|
|
173 |
print(mape)
|
174 |
|
175 |
return test_results, mse, mape
|
176 |
+
|
177 |
+
|
178 |
global results
|
179 |
|
180 |
|