Shafeek Saleem commited on
Commit
e764c4e
·
1 Parent(s): 86f0228
Files changed (1) hide show
  1. 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.info("Upload the dataset which has weather related attributes for model training in .csv format.")
142
  # Display the image and information in a grid layout
143
- col1 = st.columns([1])
144
-
145
- with col1[0]:
146
- # data = {
147
- # 'Timestamp': ['11/1/2022 0:20', '11/1/2022 0:25'],
148
- # 'Total_Power (kW)': [37337, 44590],
149
- # 'PV_Output': [296.6, 298.4],
150
- # 'Solar_Irradiance': [0, 0],
151
- # 'Temperature': [25.1, 24.7],
152
- # 'Rain_Fall': [42.6, 42.6],
153
- # 'Wind_Speed': [0.6, 0.4]
154
- # }
155
- csv_file = st.file_uploader("Upload CSV", type=['csv'])
156
- if csv_file is not None:
157
- data = process_file(csv_file)
158
- df = pd.DataFrame(data)
159
- st.subheader("Example of CSV file DataFrame")
160
- st.dataframe(df)
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)
 
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)