Bayhaqy commited on
Commit
b9d9741
·
1 Parent(s): 1be3f11

Upload some files

Browse files
Files changed (4) hide show
  1. app.py +65 -0
  2. model.pkl +3 -0
  3. prediction.py +7 -0
  4. requirements.txt +7 -0
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from streamlit_pandas_profiling import st_profile_report
2
+ from ydata_profiling import ProfileReport
3
+ import streamlit as st
4
+ import pandas as pd
5
+ import numpy as np
6
+ from prediction import predict
7
+ from sklearn.datasets import load_iris
8
+ from ydata_profiling.utils.cache import cache_file
9
+
10
+ st.set_page_config(layout="wide")
11
+ st.title('Iris Flowers - Classification')
12
+ st.caption('Created by Bayhaqy')
13
+ st.markdown('Classify iris flowers into \
14
+ setosa, versicolor, virginica')
15
+
16
+ st.image('https://machinelearninghd.com/wp-content/uploads/2021/03/iris-dataset.png')
17
+ st.image('https://www.integratedots.com/wp-content/uploads/2019/06/iris_petal-sepal-e1560211020463.png')
18
+
19
+ # Load Dataset
20
+ #iris = load_iris(as_frame=True)
21
+
22
+ @st.cache_data
23
+ def load_data(url):
24
+ df = pd.read_csv(url)
25
+ return df
26
+
27
+ iris = cache_file(
28
+ 'Iris.csv',
29
+ 'https://raw.githubusercontent.com/bayhaqy/Classification-Iris-Prediction/main/Iris.csv',
30
+ )
31
+
32
+ df = load_data(iris)
33
+
34
+ # Create a DataFrame from the iris data
35
+ #df = pd.DataFrame(iris.data, columns=iris.feature_names)
36
+
37
+ # Add a target column to the DataFrame
38
+ #df['Target'] = iris['target']
39
+
40
+ # Translate the target
41
+ #df['Target'] = df['Target'].apply(lambda x: iris['target_names'][x])
42
+
43
+ st.header('Plant Features')
44
+ col1, col2 = st.columns(2)
45
+ with col1:
46
+ st.text('Sepal Size')
47
+ sepal_l = st.slider('Sepal lenght (cm)', 1.0, 8.0, 0.5)
48
+ sepal_w = st.slider('Sepal width (cm)', 2.0, 4.4, 0.5)
49
+
50
+ with col2:
51
+ st.text('Pepal Size')
52
+ petal_l = st.slider('Petal lenght (cm)', 1.0, 7.0, 0.5)
53
+ petal_w = st.slider('Petal width (cm)', 0.1, 2.5, 0.5)
54
+
55
+ if st.button('Predict type of Iris'):
56
+ result = predict(np.array([[sepal_l, sepal_w, petal_l, petal_w]]))
57
+ st.text(result[0])
58
+
59
+ st.write("---")
60
+ if st.checkbox("Sample preview the Iris Dataset"):
61
+ #st.write(df.sample(10)) # Same as st.write(df)
62
+ pr = ProfileReport(df,title="Dataset Report")
63
+ st_profile_report(pr)
64
+
65
+ st.write("---")
model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba4bce9f362b6cf4fbf1de5c2292cab5e11f854a7da038eadf23ec2b82648341
3
+ size 4228
prediction.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+
4
+ @st.cache_resource
5
+ def predict(data):
6
+ model = pickle.load(open('model.pkl', 'rb'))
7
+ return model.predict(data)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ matplotlib
2
+ ydata-profiling
3
+ streamlit-pandas-profiling
4
+ streamlit
5
+ scikit-learn
6
+ pandas
7
+ pandas-profiling