Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 App Classifier""")
|
7 |
+
st.sidebar.header('User input parameters')
|
8 |
+
|
9 |
+
def user_input_features():
|
10 |
+
sepal_length = st.sidebar.slider('Sepal length',4.3,7.8,5.0)
|
11 |
+
sepal_width = st.sidebar.slider('Sepal width',2.0,4.8,3.0)
|
12 |
+
petal_length = st.sidebar.slider('petal length',1.0,6.9,1.3)
|
13 |
+
petal_width = st.sidebar.slider('petal width',0.1,2.5,0.2)
|
14 |
+
|
15 |
+
data = {'sepal_length':sepal_length,'sepal_width':sepal_width,
|
16 |
+
'petal_length':petal_length,'petal_width':petal_width}
|
17 |
+
|
18 |
+
features = pd.DataFrame(data,index=[0])
|
19 |
+
return features
|
20 |
+
|
21 |
+
df = user_input_features()
|
22 |
+
st.write(df)
|
23 |
+
|
24 |
+
iris = datasets.load_iris()
|
25 |
+
X=iris.data
|
26 |
+
y=iris.target
|
27 |
+
|
28 |
+
clf = RandomForestClassifier()
|
29 |
+
clf.fit(X,y)
|
30 |
+
|
31 |
+
prediction = clf.predict(df)
|
32 |
+
prediction_proba = clf.predict_proba(df)
|
33 |
+
|
34 |
+
st.subheader('Class labels')
|
35 |
+
st.write(iris.target_names)
|
36 |
+
|
37 |
+
st.subheader('Prediction')
|
38 |
+
st.write(iris.target_names[prediction])
|
39 |
+
|
40 |
+
st.subheader('Prediction_Proba')
|
41 |
+
st.write(prediction_proba)
|