Raahul07 commited on
Commit
79a919a
·
verified ·
1 Parent(s): ea273c1

Upload 3 files

Browse files
Files changed (3) hide show
  1. ProjectFiles.rar +3 -0
  2. app.py +32 -0
  3. requirements.txt +2 -0
ProjectFiles.rar ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b28d208c32f538cd68920a42eb31497605bf8a5e85da6a4e9a21c62d119b5a9f
3
+ size 890
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from sklearn.datasets import load_iris
3
+ from sklearn.model_selection import train_test_split
4
+ from sklearn.ensemble import RandomForestClassifier
5
+
6
+ # 1️⃣ Load dataset and train a simple model
7
+ iris = load_iris()
8
+ X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=42)
9
+ model = RandomForestClassifier()
10
+ model.fit(X_train, y_train)
11
+
12
+ # 2️⃣ Define prediction function
13
+ def predict(sepal_length, sepal_width, petal_length, petal_width):
14
+ preds = model.predict([[sepal_length, sepal_width, petal_length, petal_width]])
15
+ return iris.target_names[preds[0]]
16
+
17
+ # 3️⃣ Create Gradio interface
18
+ inputs = [
19
+ gr.Number(label="Sepal length (cm)"),
20
+ gr.Number(label="Sepal width (cm)"),
21
+ gr.Number(label="Petal length (cm)"),
22
+ gr.Number(label="Petal width (cm)")
23
+ ]
24
+ output = gr.Textbox(label="Predicted Iris Species")
25
+
26
+ demo = gr.Interface(fn=predict, inputs=inputs, outputs=output,
27
+ title="🌸 Iris Flower Classifier",
28
+ description="Predicts the Iris species from flower dimensions.")
29
+
30
+ # 4️⃣ Launch app
31
+ if __name__ == "__main__":
32
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ scikit-learn