Spaces:
No application file
No application file
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
from sklearn.linear_model import LogisticRegression
|
| 4 |
+
from sklearn.model_selection import train_test_split
|
| 5 |
+
|
| 6 |
+
st.title("馃摌 Ejemplo educativo de Machine Learning en Python")
|
| 7 |
+
|
| 8 |
+
# Cargar datos
|
| 9 |
+
data = pd.read_csv("data.csv")
|
| 10 |
+
|
| 11 |
+
st.subheader("馃搳 Datos utilizados")
|
| 12 |
+
st.dataframe(data)
|
| 13 |
+
|
| 14 |
+
# Variables
|
| 15 |
+
X = data[["horas_estudio", "asistencia"]]
|
| 16 |
+
y = data["aprueba"]
|
| 17 |
+
|
| 18 |
+
# Entrenar modelo
|
| 19 |
+
modelo = LogisticRegression()
|
| 20 |
+
modelo.fit(X, y)
|
| 21 |
+
|
| 22 |
+
st.subheader("馃 Modelo entrenado")
|
| 23 |
+
|
| 24 |
+
# Inputs del usuario
|
| 25 |
+
horas = st.slider("Horas de estudio", 0, 10, 4)
|
| 26 |
+
asistencia = st.slider("Asistencia (%)", 0, 100, 75)
|
| 27 |
+
|
| 28 |
+
# Predicci贸n
|
| 29 |
+
prediccion = modelo.predict([[horas, asistencia]])
|
| 30 |
+
|
| 31 |
+
st.subheader("馃攳 Resultado")
|
| 32 |
+
if prediccion[0] == 1:
|
| 33 |
+
st.success("El modelo predice que APRUEBA")
|
| 34 |
+
else:
|
| 35 |
+
st.error("El modelo predice que NO aprueba")
|