Spaces:
Sleeping
Sleeping
Shafeek Saleem
commited on
Commit
·
86f0228
1
Parent(s):
2e8500a
ss
Browse files- pages/3_Training the Model.py +42 -43
pages/3_Training the Model.py
CHANGED
|
@@ -137,53 +137,52 @@ def tuned_parameters(model):
|
|
| 137 |
|
| 138 |
def step3_page():
|
| 139 |
st.header("Training the Model")
|
| 140 |
-
st.subheader("
|
| 141 |
-
st.
|
| 142 |
-
|
| 143 |
# Display the image and information in a grid layout
|
| 144 |
col1 = st.columns([1])
|
| 145 |
|
| 146 |
with col1[0]:
|
| 147 |
-
data = {
|
| 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 |
|
| 188 |
if st.button("Complete"):
|
| 189 |
complete_level(LEVEL)
|
|
|
|
| 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)
|