Jasonntone commited on
Commit
879c2b6
1 Parent(s): 2f1fc0d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st # type: ignore
2
+ import pandas as pd
3
+ from sklearn import datasets
4
+ from sklearn.ensemble import RandomForestClassifier
5
+
6
+ st.title('Iris Flower Prediction App')
7
+ iris = datasets.load_iris()
8
+ X = iris.data
9
+ y = iris.target
10
+
11
+ clf = RandomForestClassifier()
12
+ clf.fit(X,y)
13
+
14
+ st.sidebar.header('User Input Parameters')
15
+
16
+ def user_input_features():
17
+ sepal_length = st.sidebar.slider('Sepal length' ,4.3,8.0,5.0)
18
+ sepal_width = st.sidebar.slider('Sepal width' ,2.0,4.4,3.4)
19
+ pepal_length = st.sidebar.slider('Petal length' ,1.0,6.9,1.3)
20
+ petal_width = st.sidebar.slider('Petal width' ,0.1,2.5,0.2)
21
+ data ={'sepal_length':sepal_length,
22
+ 'sepal_width':sepal_width,
23
+ 'petal_length':pepal_length,
24
+ 'petal_width':petal_width}
25
+ features = pd.DataFrame(data,index=[0])
26
+ return features
27
+
28
+
29
+ df = user_input_features()
30
+ st.subheader('User Input Parameters')
31
+ st.write(df)
32
+
33
+ prediction = clf.predict(df)
34
+ prediction_proba = clf.predict_proba(df)
35
+
36
+ st.subheader('Class names and corresponding numbers')
37
+ st.write(iris.target_names)
38
+
39
+ st.subheader('Prediction')
40
+ st.write(iris.target_names[prediction])
41
+
42
+ st.subheader('Prediction Probability')
43
+ st.write(prediction_proba )