Spaces:
Sleeping
Sleeping
File size: 1,096 Bytes
a7ee9ab |
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 |
import streamlit as st
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
st.title("""Iris App Classifier""")
st.sidebar.header('User input parameters')
def user_input_features():
sepal_length = st.sidebar.slider('Sepal length',4.3,7.8,5.0)
sepal_width = st.sidebar.slider('Sepal width',2.0,4.8,3.0)
petal_length = st.sidebar.slider('petal length',1.0,6.9,1.3)
petal_width = st.sidebar.slider('petal width',0.1,2.5,0.2)
data = {'sepal_length':sepal_length,'sepal_width':sepal_width,
'petal_length':petal_length,'petal_width':petal_width}
features = pd.DataFrame(data,index=[0])
return features
df = user_input_features()
st.write(df)
iris = datasets.load_iris()
X=iris.data
y=iris.target
clf = RandomForestClassifier()
clf.fit(X,y)
prediction = clf.predict(df)
prediction_proba = clf.predict_proba(df)
st.subheader('Class labels')
st.write(iris.target_names)
st.subheader('Prediction')
st.write(iris.target_names[prediction])
st.subheader('Prediction_Proba')
st.write(prediction_proba) |