ChinmayBH commited on
Commit
66ea3b2
·
verified ·
1 Parent(s): d3e57c7

streamlit UI changes

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -3,7 +3,6 @@ import numpy as np
3
  import pandas as pd
4
  from sklearn.model_selection import train_test_split
5
  from sklearn.neighbors import KNeighborsClassifier
6
-
7
  def train_iris_model():
8
  df = pd.read_csv("Iris.csv")
9
  df['Species'] = df['Species'].map({'Iris-setosa': 0, 'Iris-virginica': 1, 'Iris-versicolor': 2})
@@ -29,10 +28,11 @@ def predict_iris_species(model, input_data):
29
  def main():
30
  st.title("Iris Species Prediction App")
31
 
32
- sepal_length = st.slider("Sepal Length", 0.0, 10.0, 5.0)
33
- sepal_width = st.slider("Sepal Width", 0.0, 10.0, 5.0)
34
- petal_length = st.slider("Petal Length", 0.0, 10.0, 5.0)
35
- petal_width = st.slider("Petal Width", 0.0, 10.0, 5.0)
 
36
 
37
  trained_model = train_iris_model()
38
  input_values = [sepal_length, sepal_width, petal_length, petal_width]
@@ -41,7 +41,14 @@ def main():
41
  species_mapping = {0: 'Iris-setosa', 1: 'Iris-virginica', 2: 'Iris-versicolor'}
42
  predicted_species = species_mapping.get(prediction_result[0], 'Unknown')
43
 
44
- st.write(f"Predicted Species: {predicted_species}")
 
 
 
 
 
 
 
45
 
46
  if __name__ == "__main__":
47
  main()
 
3
  import pandas as pd
4
  from sklearn.model_selection import train_test_split
5
  from sklearn.neighbors import KNeighborsClassifier
 
6
  def train_iris_model():
7
  df = pd.read_csv("Iris.csv")
8
  df['Species'] = df['Species'].map({'Iris-setosa': 0, 'Iris-virginica': 1, 'Iris-versicolor': 2})
 
28
  def main():
29
  st.title("Iris Species Prediction App")
30
 
31
+ st.sidebar.header("User Input")
32
+ sepal_length = st.sidebar.slider("Sepal Length", 0.0, 10.0, 5.0)
33
+ sepal_width = st.sidebar.slider("Sepal Width", 0.0, 10.0, 5.0)
34
+ petal_length = st.sidebar.slider("Petal Length", 0.0, 10.0, 5.0)
35
+ petal_width = st.sidebar.slider("Petal Width", 0.0, 10.0, 5.0)
36
 
37
  trained_model = train_iris_model()
38
  input_values = [sepal_length, sepal_width, petal_length, petal_width]
 
41
  species_mapping = {0: 'Iris-setosa', 1: 'Iris-virginica', 2: 'Iris-versicolor'}
42
  predicted_species = species_mapping.get(prediction_result[0], 'Unknown')
43
 
44
+ st.subheader("User Input Values:")
45
+ st.write(f"- Sepal Length: {sepal_length}")
46
+ st.write(f"- Sepal Width: {sepal_width}")
47
+ st.write(f"- Petal Length: {petal_length}")
48
+ st.write(f"- Petal Width: {petal_width}")
49
+
50
+ st.subheader("Prediction:")
51
+ st.success(f"Predicted Species: {predicted_species}")
52
 
53
  if __name__ == "__main__":
54
  main()