harikrishnad1997 commited on
Commit
a346046
1 Parent(s): e5b1d42

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -78
app.py CHANGED
@@ -1,91 +1,68 @@
1
- from operator import index
2
  import streamlit as st
3
- import plotly.express as px
4
- import numpy as np
5
- from lazypredict.Supervised import LazyRegressor, LazyClassifier
6
- from sklearn.model_selection import train_test_split
7
  import pandas as pd
8
- from autoviz.AutoViz_Class import AutoViz_Class
9
- from sklearn.datasets import load_iris
10
- import os
11
 
12
- @st.cache_resource
13
- def load_data():
14
- X, y = load_iris(return_X_y=True)
15
- df = pd.DataFrame(X, columns=["sepal_length", "sepal_width", "petal_length", "petal_width"])
16
- df['target'] = y
17
- return df
18
 
19
- df = load_data()
 
 
20
 
21
- with st.sidebar:
22
- st.image("https://analyticsindiamag.com/wp-content/uploads/2020/10/lazypredict.jpg")
23
- st.title("AutoML")
24
- choice = st.radio("Navigation", ["Upload", "Profiling", "Modelling", "Download"])
25
- st.info("This project application helps you build and explore your data.")
26
 
27
- if choice == "Upload":
28
- st.title("Upload Your Dataset")
29
- file = st.file_uploader("Upload Your Dataset")
30
- if file:
31
- df = pd.read_csv(file, index_col=None)
32
- df.to_csv('dataset.csv', index=None)
33
- st.dataframe(df)
34
 
35
- if choice == "Profiling":
36
- st.title("Exploratory Data Analysis")
37
- # AV = AutoViz_Class()
38
- # config = {
39
- # 'filename': None,
40
- # 'sep': ',',
41
- # 'depVar': '',
42
- # 'dfte': df,
43
- # 'header': 0,
44
- # 'verbose': 0,
45
- # 'lowess': False,
46
- # 'chart_format': 'html',
47
- # 'max_rows_analyzed': 10000,
48
- # 'max_cols_analyzed': 50,
49
- # # 'save_plot_path': None,
50
- # }
51
- # AV.AutoViz()
52
- # st.components.v1.html(AV.html, width=1000, height=1000, scrolling=True)
53
-
54
- AV = AutoViz_Class()
55
- AV.AutoViz("",dfte=df)
56
- report_path = os.path.join(os.path.dirname(__file__), "autoviz_report.html")
57
- try:
58
- AV.save_html(report_path)
59
- HtmlFile = open(report_path, 'r', encoding='utf-8')
60
- source_code = HtmlFile.read()
61
- st.components.v1.html(source_code, width=1000, height=1000, scrolling=True)
62
- except:
63
- st.write("Error occurred while generating the AutoViz report.")
64
 
 
 
 
65
 
66
- if choice == "Modelling":
67
- target_options = df.columns.tolist()
68
- chosen_target = st.selectbox('Choose the Target Column', target_options)
69
- model_type = st.selectbox('Choose Model Type', ['Regression', 'Classification'])
70
- if st.button('Run Modelling'):
71
- X = df.drop(chosen_target, axis=1)
72
- y = df[chosen_target]
73
 
74
- X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.5, random_state=65481254)
 
 
 
75
 
76
- if model_type == 'Classification':
77
- # Classification
78
- clf = LazyClassifier(verbose=0, ignore_warnings=False, custom_metric=None)
79
- models, predictions = clf.fit(X_train, X_test, y_train, y_test)
80
- model_dictionary = clf.provide_models(X_train, X_test, y_train, y_test)
81
- else:
82
- # Regression
83
- reg = LazyRegressor(verbose=0, ignore_warnings=False, custom_metric=None)
84
- models, predictions = reg.fit(X_train, X_test, y_train, y_test)
85
- model_dictionary = reg.provide_models(X_train, X_test, y_train, y_test)
86
 
87
- st.dataframe(models)
 
 
 
88
 
89
- if choice == "Download":
90
- with open('model_dictionary.pkl', 'wb') as f:
91
- st.download_button('Download Model', f, file_name="model_dictionary.pkl")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
2
  import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
 
5
 
6
+ # Load the Iris dataset
7
+ iris_df = sns.load_dataset('iris')
 
 
 
 
8
 
9
+ # Sidebar for file upload and dataset selection
10
+ st.sidebar.title('Upload CSV File')
11
+ uploaded_file = st.sidebar.file_uploader("Choose a CSV file", type=['csv'])
12
 
13
+ if uploaded_file is not None:
14
+ # Read the uploaded file
15
+ custom_df = pd.read_csv(uploaded_file)
 
 
16
 
17
+ # Display the uploaded dataset
18
+ st.write('**Uploaded Dataset:**')
19
+ st.write(custom_df.head())
 
 
 
 
20
 
21
+ # Sidebar for plot selection
22
+ plot_type = st.sidebar.selectbox('Select Plot Type', ['Histogram', 'Scatter Plot'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
+ if plot_type == 'Histogram':
25
+ # Sidebar for selecting column
26
+ selected_column = st.sidebar.selectbox('Select Column for Histogram', custom_df.columns)
27
 
28
+ # Plot histogram
29
+ plt.figure(figsize=(8, 6))
30
+ sns.histplot(custom_df[selected_column])
31
+ st.pyplot()
 
 
 
32
 
33
+ elif plot_type == 'Scatter Plot':
34
+ # Sidebar for selecting columns
35
+ x_axis = st.sidebar.selectbox('Select X-Axis Column', custom_df.columns)
36
+ y_axis = st.sidebar.selectbox('Select Y-Axis Column', custom_df.columns)
37
 
38
+ # Plot scatter plot
39
+ plt.figure(figsize=(8, 6))
40
+ sns.scatterplot(x=x_axis, y=y_axis, data=custom_df)
41
+ st.pyplot()
 
 
 
 
 
 
42
 
43
+ else:
44
+ # Display the default dataset
45
+ st.write('**Default Dataset (Iris):**')
46
+ st.write(iris_df.head())
47
 
48
+ # Sidebar for plot selection
49
+ plot_type = st.sidebar.selectbox('Select Plot Type', ['Histogram', 'Scatter Plot'])
50
+
51
+ if plot_type == 'Histogram':
52
+ # Sidebar for selecting column
53
+ selected_column = st.sidebar.selectbox('Select Column for Histogram', iris_df.columns)
54
+
55
+ # Plot histogram
56
+ plt.figure(figsize=(8, 6))
57
+ sns.histplot(iris_df[selected_column])
58
+ st.pyplot()
59
+
60
+ elif plot_type == 'Scatter Plot':
61
+ # Sidebar for selecting columns
62
+ x_axis = st.sidebar.selectbox('Select X-Axis Column', iris_df.columns)
63
+ y_axis = st.sidebar.selectbox('Select Y-Axis Column', iris_df.columns)
64
+
65
+ # Plot scatter plot
66
+ plt.figure(figsize=(8, 6))
67
+ sns.scatterplot(x=x_axis, y=y_axis, data=iris_df)
68
+ st.pyplot()