Antonio49 commited on
Commit
de06da7
1 Parent(s): b546739

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -15
app.py CHANGED
@@ -1,28 +1,38 @@
1
  import gradio as gr
 
 
2
 
3
  import pickle
4
- with open('modelo.pkl', 'rb') as file:
5
  knn = pickle.load(file)
6
 
 
 
 
 
 
 
 
 
7
  def modelo(sepal_length, sepal_width, petal_length, petal_width):
8
- species = ['Iris-Setosa', 'Iris-Versicolour', 'Iris-Virginica']
9
- i = knn.predict([[sepal_length, sepal_width, petal_length, petal_width]])[0]
10
- return species[i]
11
 
12
  interfaz = gr.Interface(
13
  fn=modelo,
14
  inputs=[
15
- gr.inputs.Slider(minimum=0.0, maximum=8.0, step=0.1, default=0.0, label='Sepal Length', optional=False),
16
- gr.inputs.Slider(minimum=0.0, maximum=8.0, step=0.1, default=0.0, label='Sepal Width', optional=False),
17
- gr.inputs.Slider(minimum=0.0, maximum=8.0, step=0.1, default=0.0, label='Petal Length', optional=False),
18
- gr.inputs.Slider(minimum=0.0, maximum=8.0, step=0.1, default=0.0, label='Petal Width', optional=False)
19
  ],
20
- outputs= gr.outputs.Textbox(type="email", label='Specie'),
21
- examples= [[6.7, 3.0, 5.2, 2.3], [4.7, 3.2, 1.3, 0.2], [5.0, 3.6, 1.4, 0.2]],
22
- title = 'Detector de especies de iris',
23
- description = 'Este modelo est谩 desarrollado para la clasificaci贸n de flores de la especie Iris.',
24
- article = 'Aplicaci贸n desarrollada con fines docentes en el curso Saturdays.ai',
25
- theme = 'peach'
26
  )
27
 
28
- interfaz.launch()
 
 
1
  import gradio as gr
2
+ import numpy as np
3
+ from sklearn.neighbors import KNeighborsClassifier
4
 
5
  import pickle
6
+ with open('modelo (3).pkl', 'rb') as file:
7
  knn = pickle.load(file)
8
 
9
+
10
+
11
+ # Crear un modelo KNN de ejemplo para que funcione el c贸digo
12
+ #knn = KNeighborsClassifier(n_neighbors=3)
13
+ #X = np.array([[6.7, 3.0, 5.2, 2.3], [4.7, 3.2, 1.3, 0.2], [5.0, 3.6, 1.4, 0.2]])
14
+ #y = np.array([0, 1, 2])
15
+ #knn.fit(X, y)
16
+
17
  def modelo(sepal_length, sepal_width, petal_length, petal_width):
18
+ species = ['Iris-Setosa', 'Iris-Versicolour', 'Iris-Virginica']
19
+ i = knn.predict([[sepal_length, sepal_width, petal_length, petal_width]])[0]
20
+ return species[i]
21
 
22
  interfaz = gr.Interface(
23
  fn=modelo,
24
  inputs=[
25
+ gr.Slider(label='Sepal Length', minimum=0.0, maximum=8.0, step=0.1),
26
+ gr.Slider(label='Sepal Width', minimum=0.0, maximum=8.0, step=0.1),
27
+ gr.Slider(label='Petal Length', minimum=0.0, maximum=8.0, step=0.1),
28
+ gr.Slider(label='Petal Width', minimum=0.0, maximum=8.0, step=0.1),
29
  ],
30
+ outputs=gr.Textbox(label='Specie'),
31
+ title='Detector de especies de iris',
32
+ description='Este modelo est谩 desarrollado para la clasificaci贸n de flores de la especie Iris.',
33
+ article='Aplicaci贸n desarrollada con fines docentes en el curso Saturdays.ai',
34
+ theme='peach'
 
35
  )
36
 
37
+ interfaz.launch()
38
+