Spaces:
Sleeping
Sleeping
Commit
·
75bda9c
1
Parent(s):
fb052eb
Create dd
Browse files
dd
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from sklearn import datasets
|
3 |
+
from sklearn.model_selection import train_test_split
|
4 |
+
from sklearn import svm
|
5 |
+
from sklearn import metrics
|
6 |
+
|
7 |
+
# Load Iris dataset
|
8 |
+
iris = datasets.load_iris()
|
9 |
+
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)
|
10 |
+
|
11 |
+
# Train a Support Vector Classifier
|
12 |
+
clf = svm.SVC(kernel='linear')
|
13 |
+
clf.fit(X_train, y_train)
|
14 |
+
|
15 |
+
def iris_classifier(sepal_length, sepal_width, petal_length, petal_width):
|
16 |
+
prediction = clf.predict([[sepal_length, sepal_width, petal_length, petal_width]])
|
17 |
+
return iris.target_names[prediction[0]]
|
18 |
+
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=iris_classifier,
|
21 |
+
inputs=["number", "number", "number", "number"],
|
22 |
+
outputs="text",
|
23 |
+
title="Iris Classifier",
|
24 |
+
description="Enter the measurements of an iris flower to predict its species."
|
25 |
+
)
|
26 |
+
iface.launch()
|