Oceane22 commited on
Commit
281a20b
1 Parent(s): b8e7061

Create app.py

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