munta commited on
Commit
0ab8b8f
1 Parent(s): 4eb779f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -0
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import streamlit as st
 
2
 
3
  with st.form(key='my_form'):
4
  sLen = st.slider('Sepal lenght(cm) ', 0.0, 10.0)
@@ -6,3 +7,10 @@ with st.form(key='my_form'):
6
  pLen = st.slider('Petal lenght(cm) ', 0.0, 10.0)
7
  pWid = st.slider('Petal width(cm) ', 0.0, 10.0)
8
  st.form_submit_button('Predict')
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from sklearn import neighbors, datasets
3
 
4
  with st.form(key='my_form'):
5
  sLen = st.slider('Sepal lenght(cm) ', 0.0, 10.0)
 
7
  pLen = st.slider('Petal lenght(cm) ', 0.0, 10.0)
8
  pWid = st.slider('Petal width(cm) ', 0.0, 10.0)
9
  st.form_submit_button('Predict')
10
+
11
+ iris = datasets.load_iris()
12
+ X,y = iris.data, iris.target
13
+ knn = neighbors.KNeighborsClassifier(n_neighbors=2) #k = 3,4,5,6
14
+ knn.fit(X,y)
15
+ predict = knn.predict([[sLen,sWid,pLen,pWid]])
16
+ print(iris.target_names[knn.predict([[3,5,4,2]])])