Spaces:
Sleeping
Sleeping
Agrega texto y quita botón flag
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
from datasets import load_dataset
|
@@ -76,10 +77,10 @@ modelo_entrenado = modelo_ajusta_train.predict_proba(X_test)
|
|
76 |
|
77 |
# Modelo Naive Bayes
|
78 |
#Creamos un objeto de Naive Bayes Multinomial
|
79 |
-
|
80 |
|
81 |
#Entrenamos el modelo con los datos de entrenamiento
|
82 |
-
|
83 |
|
84 |
# Interfaz grafica
|
85 |
def predict(Score, Age, Balance, Salary):
|
@@ -93,7 +94,7 @@ def predict(Score, Age, Balance, Salary):
|
|
93 |
else:
|
94 |
prediccion_arbol = "Se queda en el banco."
|
95 |
|
96 |
-
predicciones_naives =
|
97 |
|
98 |
if predicciones_naives == 0:
|
99 |
resultado_naives = "Se queda en el banco."
|
@@ -102,9 +103,15 @@ def predict(Score, Age, Balance, Salary):
|
|
102 |
|
103 |
return prediccion_arbol, resultado_naives
|
104 |
|
|
|
|
|
|
|
|
|
105 |
demo = gr.Interface(
|
106 |
fn=predict,
|
107 |
inputs=[gr.Slider(350, 850), "number","number","number"],
|
108 |
-
outputs=[
|
|
|
|
|
109 |
|
110 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from gradio import components
|
3 |
import pandas as pd
|
4 |
import numpy as np
|
5 |
from datasets import load_dataset
|
|
|
77 |
|
78 |
# Modelo Naive Bayes
|
79 |
#Creamos un objeto de Naive Bayes Multinomial
|
80 |
+
modelo_naives = MultinomialNB()
|
81 |
|
82 |
#Entrenamos el modelo con los datos de entrenamiento
|
83 |
+
modelo_naives.fit(X_train,y_train)
|
84 |
|
85 |
# Interfaz grafica
|
86 |
def predict(Score, Age, Balance, Salary):
|
|
|
94 |
else:
|
95 |
prediccion_arbol = "Se queda en el banco."
|
96 |
|
97 |
+
predicciones_naives = modelo_naives.predict([inputs])
|
98 |
|
99 |
if predicciones_naives == 0:
|
100 |
resultado_naives = "Se queda en el banco."
|
|
|
103 |
|
104 |
return prediccion_arbol, resultado_naives
|
105 |
|
106 |
+
output_tree = components.Textbox(label='Prueba con el modelo Tree con una sensibilidad del 0.08')
|
107 |
+
output_naives = components.Textbox(label='Prueba con el modelo Naives')
|
108 |
+
|
109 |
+
|
110 |
demo = gr.Interface(
|
111 |
fn=predict,
|
112 |
inputs=[gr.Slider(350, 850), "number","number","number"],
|
113 |
+
outputs=[output_tree, output_naives],
|
114 |
+
allow_flagging="never"
|
115 |
+
)
|
116 |
|
117 |
demo.launch()
|