-
Notifications
You must be signed in to change notification settings - Fork 0
/
iris.py
61 lines (37 loc) · 1.46 KB
/
iris.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import streamlit as st
import pandas as pd
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
st.write("""
# 🤍🤍A L I__H A S N A I N🤍🤍
# Iris Flower Prediction App
"**Ths app will predict the **Iris flower** type based on the features.**"
""")
st.sidebar.header("**YOUR INPUT PARAMETERS**")
def user_input_features():
sepal_length = st.sidebar.slider("Sepal Length", 4.3, 7.9, 5.4)
sepal_width = st.sidebar.slider("Sepal Width", 2.0, 4.4, 3.4)
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.subheader("YOUR INPUT DATA")
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 Label and their corresponding index number**")
st.write(iris.target_names)
st.subheader("**PREDICTION OF MY APP**")
st.write(iris.target_names[prediction])
st.subheader("**PROBABILITY WISE CHANCES**")
st.write(prediction_proba)