Spaces:
Sleeping
Sleeping
Shafeek Saleem
commited on
Commit
·
e764c4e
1
Parent(s):
86f0228
ss
Browse files- pages/3_Training the Model.py +45 -45
pages/3_Training the Model.py
CHANGED
@@ -137,52 +137,52 @@ def tuned_parameters(model):
|
|
137 |
|
138 |
def step3_page():
|
139 |
st.header("Training the Model")
|
140 |
-
st.subheader("Data Collection")
|
141 |
-
st.
|
142 |
# Display the image and information in a grid layout
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
|
187 |
if st.button("Complete"):
|
188 |
complete_level(LEVEL)
|
|
|
137 |
|
138 |
def step3_page():
|
139 |
st.header("Training the Model")
|
140 |
+
st.subheader("Step 1: Data Collection")
|
141 |
+
st.write("To initiate the weather forecasting model training process, kindly provide a sufficient and relevant dataset with weather-related attributes in .csv format for uploading. This dataset will be crucial for the model's training and accuracy.")
|
142 |
# Display the image and information in a grid layout
|
143 |
+
if st.button("Upload"):
|
144 |
+
col1 = st.columns([1])
|
145 |
+
with col1[0]:
|
146 |
+
csv_file = st.file_uploader("Upload CSV", type=['csv'])
|
147 |
+
if csv_file is not None:
|
148 |
+
data = process_file(csv_file)
|
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)
|