-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathML_APP.py
147 lines (104 loc) · 3.98 KB
/
ML_APP.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import streamlit as st
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
#from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.svm import SVC
from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn import model_selection
#from sklearn.preprocessing import LabelEncoder
matplotlib.use('Agg')
from PIL import Image
#Set title
st.title('JL DATA EXPRESSION')
image = Image.open("C:\\Users\\Hp\\OneDrive\\Pictures\\logo-color.png")
st.image(image,use_column_width=True)
def main():
activities=('EDA','Visualization','model','About us')
option=st.sidebar.selectbox('Select option:',activities)
#DEALING WITH THE EDA PART
if option=='EDA':
st.subheader('Exploratory Data Analysis')
data=st.file_uploader('Upload dataset:',type=['csv','xlsx','txt','json'])
st.success('Data successfully loaded')
if data is not None:
df=pd.read_csv(data)
st.dataframe(df.head(50))
if st.checkbox('Display shape'):
st.write(df.shape)
if st.checkbox('Display columns'):
st.write(df.columns)
if st.checkbox('Select multiple columns'):
selected_columns=st.multiselect('Select preferred columns:',df.columns)
df1=df[selected_columns]
st.dataframe(df1)
if st.checkbox('Display summary'):
st.write(df1.describe().T)
if st.checkbox('Display Null Values'):
st.write(df.isnull().sum())
if st.checkbox('Display rhe data types'):
st.write(df.dtypes)
if st.checkbox('Display correlation of data various columns'):
st.write(df.corr())
#DEALING WITH THE VISUALIZATION PART
elif option=='Visualization':
st.subheader("Data Visualization")
data=st.file_uploader('Upload dataset:',type=['csv','xlsx','txt','json'])
st.success('Data successfully loaded')
if data is not None:
df=pd.read_csv(data)
st.dataframe(df.head(50))
if st.checkbox('Select multiple columns to plot'):
selected_columns=st.multiselect('Select your preferred columns',df.columns)
df1=df[selected_columns]
st.dataframe(df1)
if st.checkbox('Display Heatmap'):
st.write(sns.heatmap(df1.corr(),vmax=1,square=True,annot=True,cmap='viridis'))
st.pyplot()
if st.checkbox('Display Pairplot'):
st.write(sns.pairplot(df1,diag_kind='kde'))
st.pyplot()
if st.checkbox('Display Pie Chart'):
all_columns=df.columns.to_list()
pie_columns=st.selectbox("select column to display",all_columns)
pieChart=df[pie_columns].value_counts().plot.pie(autopct="%1.1f%%")
st.set_option('deprecation.showPyplotGlobalUse', False)
st.write(pieChart)
st.pyplot()
#DEALING WITH THE MODEL BUILDING PART
elif option=='model':
st.subheader("Model Building")
data=st.file_uploader('Upload dataset:',type=['csv','xlsx','txt','json'])
st.success('Data successfully loaded')
if data is not None:
df=pd.read_csv(data)
st.dataframe(df.head(50))
if st.checkbox('Select Multiple columns'):
new_data=st.multiselect('Select your preferred columns',df.columns)
df1=df[new_data]
st.dataframe(df1)
#Dividing my data into x and y variables
X=df1.iloc[:,0:-1]
y=df1.iloc[:,-1]
seed=st.sidebar.slider('Seed',1,200)
classifier_name=st.sidebar.selectbox('Select your preferred classifier:',('KNN','SVM','LR','naive_bayes','decision tree'))
def add_parameter(name_of_clf):
param=dict()
if name_of_clf=='SVM':
C=st.sidebar.slider('C',0.01,15.0)
param['C']=C
if name_of_clf=='KNN':
K=st.sidebar.slider('K',1,15)
param['K']=K
return param
#calling the function
#params=add_parameter(classifier_name)
#define a function for our classifier
#def get_classifier(name_of_clf,params):