Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
|
|
|
| 3 |
from utils.visualizations import plot_correlation_heatmap, save_plot_as_png
|
| 4 |
-
from utils.model_training import train_all_models
|
|
|
|
| 5 |
# File uploader
|
| 6 |
st.title("Model Training with Metrics and Correlation Heatmap")
|
| 7 |
uploaded_file = st.file_uploader("Choose a CSV file", type=["csv"])
|
|
@@ -13,12 +15,12 @@ if uploaded_file is not None:
|
|
| 13 |
st.write("Dataset:")
|
| 14 |
st.dataframe(df)
|
| 15 |
|
| 16 |
-
# Clean data: Missing values, outliers, and extreme values
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
st.write("Cleaned Dataset
|
| 22 |
st.dataframe(df)
|
| 23 |
|
| 24 |
# Add clean data download option
|
|
@@ -33,9 +35,9 @@ if uploaded_file is not None:
|
|
| 33 |
# Correlation Heatmap
|
| 34 |
st.subheader("Correlation Heatmap")
|
| 35 |
corr_plot = plot_correlation_heatmap(df)
|
| 36 |
-
st.pyplot(corr_plot)
|
| 37 |
|
| 38 |
-
# Save heatmap as PNG
|
| 39 |
heatmap_buf = save_plot_as_png(corr_plot)
|
| 40 |
st.download_button(
|
| 41 |
label="Download Correlation Heatmap as PNG",
|
|
@@ -50,12 +52,6 @@ if uploaded_file is not None:
|
|
| 50 |
X = df[features]
|
| 51 |
y = df[target]
|
| 52 |
|
| 53 |
-
#
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
# Example: metrics_df = train_classification_model(X, y)
|
| 57 |
-
# st.dataframe(metrics_df)
|
| 58 |
-
else: # Regression
|
| 59 |
-
st.subheader("Regression Model Training")
|
| 60 |
-
# Example: regression_metrics_df = train_regression_model(X, y)
|
| 61 |
-
# st.dataframe(regression_metrics_df)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
from utils.data_cleaning import handle_missing_values, remove_outliers_iqr, cap_extreme_values
|
| 4 |
from utils.visualizations import plot_correlation_heatmap, save_plot_as_png
|
| 5 |
+
from utils.model_training import train_all_models
|
| 6 |
+
|
| 7 |
# File uploader
|
| 8 |
st.title("Model Training with Metrics and Correlation Heatmap")
|
| 9 |
uploaded_file = st.file_uploader("Choose a CSV file", type=["csv"])
|
|
|
|
| 15 |
st.write("Dataset:")
|
| 16 |
st.dataframe(df)
|
| 17 |
|
| 18 |
+
# Clean data: Missing values, outliers, and extreme values
|
| 19 |
+
df = handle_missing_values(df)
|
| 20 |
+
df = remove_outliers_iqr(df)
|
| 21 |
+
df = cap_extreme_values(df)
|
| 22 |
|
| 23 |
+
st.write("Cleaned Dataset:")
|
| 24 |
st.dataframe(df)
|
| 25 |
|
| 26 |
# Add clean data download option
|
|
|
|
| 35 |
# Correlation Heatmap
|
| 36 |
st.subheader("Correlation Heatmap")
|
| 37 |
corr_plot = plot_correlation_heatmap(df)
|
| 38 |
+
st.pyplot(corr_plot)
|
| 39 |
|
| 40 |
+
# Save heatmap as PNG
|
| 41 |
heatmap_buf = save_plot_as_png(corr_plot)
|
| 42 |
st.download_button(
|
| 43 |
label="Download Correlation Heatmap as PNG",
|
|
|
|
| 52 |
X = df[features]
|
| 53 |
y = df[target]
|
| 54 |
|
| 55 |
+
# Train and evaluate models
|
| 56 |
+
model_results = train_all_models(X, y) # Train all models based on data type
|
| 57 |
+
st.dataframe(model_results)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|