Canstralian commited on
Commit
33b79c3
·
verified ·
1 Parent(s): 99b01f8

Rename requirem.txtapp.py to app.pu

Browse files
Files changed (2) hide show
  1. app.pu +62 -0
  2. requirem.txtapp.py +0 -7
app.pu ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from sklearn.datasets import load_iris
4
+ from sklearn.ensemble import RandomForestClassifier
5
+ from sklearn.model_selection import train_test_split
6
+ from sklearn.metrics import accuracy_score
7
+
8
+ # Set the title of the app
9
+ st.title("Iris Flower Species Prediction App")
10
+
11
+ # Load the Iris dataset
12
+ iris = load_iris()
13
+ X = pd.DataFrame(iris.data, columns=iris.feature_names)
14
+ y = pd.Series(iris.target, name='species')
15
+
16
+ # Split the dataset into training and testing sets
17
+ X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
18
+
19
+ # Initialize the RandomForestClassifier
20
+ clf = RandomForestClassifier(n_estimators=100, random_state=42)
21
+ clf.fit(X_train, y_train)
22
+
23
+ # Sidebar for user input features
24
+ st.sidebar.header("Input Features")
25
+
26
+ def user_input_features():
27
+ sepal_length = st.sidebar.slider('Sepal length (cm)', float(X['sepal length (cm)'].min()), float(X['sepal length (cm)'].max()), float(X['sepal length (cm)'].mean()))
28
+ sepal_width = st.sidebar.slider('Sepal width (cm)', float(X['sepal width (cm)'].min()), float(X['sepal width (cm)'].max()), float(X['sepal width (cm)'].mean()))
29
+ petal_length = st.sidebar.slider('Petal length (cm)', float(X['petal length (cm)'].min()), float(X['petal length (cm)'].max()), float(X['petal length (cm)'].mean()))
30
+ petal_width = st.sidebar.slider('Petal width (cm)', float(X['petal width (cm)'].min()), float(X['petal width (cm)'].max()), float(X['petal width (cm)'].mean()))
31
+ data = {'sepal length (cm)': sepal_length,
32
+ 'sepal width (cm)': sepal_width,
33
+ 'petal length (cm)': petal_length,
34
+ 'petal width (cm)': petal_width}
35
+ features = pd.DataFrame(data, index=[0])
36
+ return features
37
+
38
+ input_df = user_input_features()
39
+
40
+ # Main panel
41
+ st.subheader("User Input Features")
42
+
43
+ # Display the user input features
44
+ st.write(input_df)
45
+
46
+ # Make predictions
47
+ prediction = clf.predict(input_df)
48
+ prediction_proba = clf.predict_proba(input_df)
49
+
50
+ # Display the prediction
51
+ st.subheader("Prediction")
52
+ st.write(iris.target_names[prediction][0])
53
+
54
+ # Display the prediction probability
55
+ st.subheader("Prediction Probability")
56
+ st.write(pd.DataFrame(prediction_proba, columns=iris.target_names))
57
+
58
+ # Evaluate model accuracy
59
+ y_pred = clf.predict(X_test)
60
+ accuracy = accuracy_score(y_test, y_pred)
61
+ st.subheader("Model Accuracy")
62
+ st.write(f"{accuracy * 100:.2f}%")
requirem.txtapp.py DELETED
@@ -1,7 +0,0 @@
1
- streamlit
2
- pandas
3
- numpy
4
- scikit-learn
5
- Pillow
6
- PyPDF2
7
- transformers