Spaces:
Sleeping
Sleeping
Shafeek Saleem
commited on
Commit
·
735aaf0
1
Parent(s):
e764c4e
ss
Browse files- pages/3_Training the Model.py +36 -32
pages/3_Training the Model.py
CHANGED
@@ -149,41 +149,45 @@ def step3_page():
|
|
149 |
df = pd.DataFrame(data)
|
150 |
st.subheader("Let's display the uploaded dataset!")
|
151 |
st.dataframe(df)
|
152 |
-
|
153 |
-
st.subheader("Step 2: Data Preprocessing and Feature Engineering")
|
154 |
-
st.write("Now let's preprocess our dataset to handle missing values, outliers and inconsistencies and then perform feature engineering tasks to extract meaningful features from the raw data. Finally we need to separate training variables (X) and target variable (y).")
|
155 |
-
if st.button("Create Features and Target variable"):
|
156 |
-
X, y = create_model_inputs(data, 288, 288)
|
157 |
-
st.subheader("Let's display the Features!")
|
158 |
-
st.dataframe(X)
|
159 |
-
st.subheader("Let's display our Target variable")
|
160 |
-
st.dataframe(y)
|
161 |
-
|
162 |
-
train_size = st.sidebar.slider("Select Train Dataset Size (%)", min_value=10, max_value=90, value=70)
|
163 |
-
|
164 |
-
models = ['LightGBM', 'Random Forest']
|
165 |
-
model_choice = st.sidebar.selectbox('Choose Model', models)
|
166 |
-
|
167 |
-
tune_model = st.sidebar.checkbox('Tune Hyperparameters')
|
168 |
-
|
169 |
-
y_test, y_pred, model = model_predict(data, model_choice, train_size, tune_model)
|
170 |
-
|
171 |
-
# Display feature importance
|
172 |
-
if st.sidebar.checkbox('Show feature importance'):
|
173 |
-
feature_names = ['Solar_Irradiance', 'Temperature', 'Rain_Fall', 'Wind_speed', 'PV_Output_lag',
|
174 |
-
'PV_Output_mean']
|
175 |
-
fig = feature_importance_plot(model, feature_names)
|
176 |
-
with _lock:
|
177 |
-
st.pyplot(fig)
|
178 |
-
|
179 |
-
fig = show_output(y_test, y_pred)
|
180 |
-
|
181 |
-
download_link(y_test, y_pred)
|
182 |
-
|
183 |
-
download_plot(fig)
|
184 |
else:
|
185 |
st.error("Please upload a valid .csv file")
|
186 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
if st.button("Complete"):
|
188 |
complete_level(LEVEL)
|
189 |
|
|
|
149 |
df = pd.DataFrame(data)
|
150 |
st.subheader("Let's display the uploaded dataset!")
|
151 |
st.dataframe(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
else:
|
153 |
st.error("Please upload a valid .csv file")
|
154 |
|
155 |
+
st.subheader("Step 2: Data Preprocessing and Feature Engineering")
|
156 |
+
st.write("Now let's preprocess our dataset to handle missing values, outliers and inconsistencies and then perform feature engineering tasks to extract meaningful features from the raw data. Finally we need to separate training variables (X) and target variable (y).")
|
157 |
+
if st.button("Create Features and Target variable"):
|
158 |
+
X, y = create_model_inputs(data, 288, 288)
|
159 |
+
col1, col2 = st.columns([2])
|
160 |
+
with col1:
|
161 |
+
st.subheader("Let's display the Features!")
|
162 |
+
st.dataframe(X)
|
163 |
+
with col2:
|
164 |
+
st.subheader("Let's display our Target variable")
|
165 |
+
st.dataframe(y)
|
166 |
+
|
167 |
+
# train_size = st.sidebar.slider("Select Train Dataset Size (%)", min_value=10, max_value=90, value=70)
|
168 |
+
#
|
169 |
+
# models = ['LightGBM', 'Random Forest']
|
170 |
+
# model_choice = st.sidebar.selectbox('Choose Model', models)
|
171 |
+
#
|
172 |
+
# tune_model = st.sidebar.checkbox('Tune Hyperparameters')
|
173 |
+
#
|
174 |
+
# y_test, y_pred, model = model_predict(data, model_choice, train_size, tune_model)
|
175 |
+
#
|
176 |
+
# # Display feature importance
|
177 |
+
# if st.sidebar.checkbox('Show feature importance'):
|
178 |
+
# feature_names = ['Solar_Irradiance', 'Temperature', 'Rain_Fall', 'Wind_speed', 'PV_Output_lag',
|
179 |
+
# 'PV_Output_mean']
|
180 |
+
# fig = feature_importance_plot(model, feature_names)
|
181 |
+
# with _lock:
|
182 |
+
# st.pyplot(fig)
|
183 |
+
#
|
184 |
+
# fig = show_output(y_test, y_pred)
|
185 |
+
#
|
186 |
+
# download_link(y_test, y_pred)
|
187 |
+
#
|
188 |
+
# download_plot(fig)
|
189 |
+
|
190 |
+
|
191 |
if st.button("Complete"):
|
192 |
complete_level(LEVEL)
|
193 |
|