File size: 910 Bytes
cced052
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bf16268
 
cced052
bf16268
 
 
cced052
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr
import seaborn as sns
df=sns.load_dataset('iris')

x=df.drop(columns="species")
y=df["species"]

from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier



x_train, x_test, y_train, y_test= train_test_split(x,y, train_size=0.8 , random_state=42)
model=KNeighborsClassifier(n_neighbors=3)
model.fit(x_train, y_train)

accuracy = model.score(x_test, y_test)

def greet(sepal_length,sepal_weidth,petal_length,petal_weidth):
    return  model.predict([[sepal_length,sepal_weidth,petal_length,petal_weidth]])

iface = gr.Interface(fn=greet, description="you have to give the 4 values sepal_length, sepal_weidth, petal_length and petal_weidth amd the project will predict the specie", 
                     title="iris flower species classifier", 
                     inputs=["number","number","number","number"], outputs="textbox")
iface.launch()