Spaces:
Sleeping
Sleeping
Upload 51 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +30 -0
- ESCUDOS/Arsenal.png +3 -0
- ESCUDOS/Aston Villa.png +3 -0
- ESCUDOS/Birmingham.png +3 -0
- ESCUDOS/Blackburn.png +3 -0
- ESCUDOS/Blackpool.png +3 -0
- ESCUDOS/Bolton.png +0 -0
- ESCUDOS/Bournemouth.png +0 -0
- ESCUDOS/Bradford.png +3 -0
- ESCUDOS/Brentford.png +3 -0
- ESCUDOS/Brighton.png +0 -0
- ESCUDOS/Burnley.png +0 -0
- ESCUDOS/Cardiff.png +3 -0
- ESCUDOS/Charlton.png +3 -0
- ESCUDOS/Chelsea.png +3 -0
- ESCUDOS/Coventry.png +3 -0
- ESCUDOS/Crystal Palace.png +0 -0
- ESCUDOS/Derby.png +3 -0
- ESCUDOS/Everton.png +3 -0
- ESCUDOS/Fulham.png +0 -0
- ESCUDOS/Huddersfield.png +3 -0
- ESCUDOS/Hull.png +3 -0
- ESCUDOS/Leeds.png +0 -0
- ESCUDOS/Leicester.png +3 -0
- ESCUDOS/Liverpool.png +3 -0
- ESCUDOS/Luton.png +3 -0
- ESCUDOS/Man City.png +3 -0
- ESCUDOS/Man United.png +3 -0
- ESCUDOS/Middlesbrough.png +3 -0
- ESCUDOS/Newcastle.png +3 -0
- ESCUDOS/Norwich.png +0 -0
- ESCUDOS/Nott'm Forest.png +0 -0
- ESCUDOS/PREMIER.png +0 -0
- ESCUDOS/Portsmouth.png +3 -0
- ESCUDOS/QPR.png +3 -0
- ESCUDOS/Reading.png +3 -0
- ESCUDOS/Sheffield United.png +3 -0
- ESCUDOS/Southampton.png +3 -0
- ESCUDOS/Stoke.png +0 -0
- ESCUDOS/Sunderland.png +3 -0
- ESCUDOS/Swansea.png +0 -0
- ESCUDOS/Tottenham.png +0 -0
- ESCUDOS/Watford.png +0 -0
- ESCUDOS/West Brom.png +3 -0
- ESCUDOS/West Ham.png +0 -0
- ESCUDOS/Wigan.png +3 -0
- ESCUDOS/Wolves.png +0 -0
- ESCUDOS/ipswich.png +0 -0
- GRADIO.py +143 -0
- datos_premier_consolidado.csv +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,33 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
ESCUDOS/Arsenal.png filter=lfs diff=lfs merge=lfs -text
|
37 |
+
ESCUDOS/Aston[[:space:]]Villa.png filter=lfs diff=lfs merge=lfs -text
|
38 |
+
ESCUDOS/Birmingham.png filter=lfs diff=lfs merge=lfs -text
|
39 |
+
ESCUDOS/Blackburn.png filter=lfs diff=lfs merge=lfs -text
|
40 |
+
ESCUDOS/Blackpool.png filter=lfs diff=lfs merge=lfs -text
|
41 |
+
ESCUDOS/Bradford.png filter=lfs diff=lfs merge=lfs -text
|
42 |
+
ESCUDOS/Brentford.png filter=lfs diff=lfs merge=lfs -text
|
43 |
+
ESCUDOS/Cardiff.png filter=lfs diff=lfs merge=lfs -text
|
44 |
+
ESCUDOS/Charlton.png filter=lfs diff=lfs merge=lfs -text
|
45 |
+
ESCUDOS/Chelsea.png filter=lfs diff=lfs merge=lfs -text
|
46 |
+
ESCUDOS/Coventry.png filter=lfs diff=lfs merge=lfs -text
|
47 |
+
ESCUDOS/Derby.png filter=lfs diff=lfs merge=lfs -text
|
48 |
+
ESCUDOS/Everton.png filter=lfs diff=lfs merge=lfs -text
|
49 |
+
ESCUDOS/Huddersfield.png filter=lfs diff=lfs merge=lfs -text
|
50 |
+
ESCUDOS/Hull.png filter=lfs diff=lfs merge=lfs -text
|
51 |
+
ESCUDOS/Leicester.png filter=lfs diff=lfs merge=lfs -text
|
52 |
+
ESCUDOS/Liverpool.png filter=lfs diff=lfs merge=lfs -text
|
53 |
+
ESCUDOS/Luton.png filter=lfs diff=lfs merge=lfs -text
|
54 |
+
ESCUDOS/Man[[:space:]]City.png filter=lfs diff=lfs merge=lfs -text
|
55 |
+
ESCUDOS/Man[[:space:]]United.png filter=lfs diff=lfs merge=lfs -text
|
56 |
+
ESCUDOS/Middlesbrough.png filter=lfs diff=lfs merge=lfs -text
|
57 |
+
ESCUDOS/Newcastle.png filter=lfs diff=lfs merge=lfs -text
|
58 |
+
ESCUDOS/Portsmouth.png filter=lfs diff=lfs merge=lfs -text
|
59 |
+
ESCUDOS/QPR.png filter=lfs diff=lfs merge=lfs -text
|
60 |
+
ESCUDOS/Reading.png filter=lfs diff=lfs merge=lfs -text
|
61 |
+
ESCUDOS/Sheffield[[:space:]]United.png filter=lfs diff=lfs merge=lfs -text
|
62 |
+
ESCUDOS/Southampton.png filter=lfs diff=lfs merge=lfs -text
|
63 |
+
ESCUDOS/Sunderland.png filter=lfs diff=lfs merge=lfs -text
|
64 |
+
ESCUDOS/West[[:space:]]Brom.png filter=lfs diff=lfs merge=lfs -text
|
65 |
+
ESCUDOS/Wigan.png filter=lfs diff=lfs merge=lfs -text
|
ESCUDOS/Arsenal.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Aston Villa.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Birmingham.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Blackburn.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Blackpool.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Bolton.png
ADDED
![]() |
ESCUDOS/Bournemouth.png
ADDED
![]() |
ESCUDOS/Bradford.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Brentford.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Brighton.png
ADDED
![]() |
ESCUDOS/Burnley.png
ADDED
![]() |
ESCUDOS/Cardiff.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Charlton.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Chelsea.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Coventry.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Crystal Palace.png
ADDED
![]() |
ESCUDOS/Derby.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Everton.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Fulham.png
ADDED
![]() |
ESCUDOS/Huddersfield.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Hull.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Leeds.png
ADDED
![]() |
ESCUDOS/Leicester.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Liverpool.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Luton.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Man City.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Man United.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Middlesbrough.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Newcastle.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Norwich.png
ADDED
![]() |
ESCUDOS/Nott'm Forest.png
ADDED
![]() |
ESCUDOS/PREMIER.png
ADDED
![]() |
ESCUDOS/Portsmouth.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/QPR.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Reading.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Sheffield United.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Southampton.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Stoke.png
ADDED
![]() |
ESCUDOS/Sunderland.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Swansea.png
ADDED
![]() |
ESCUDOS/Tottenham.png
ADDED
![]() |
ESCUDOS/Watford.png
ADDED
![]() |
ESCUDOS/West Brom.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/West Ham.png
ADDED
![]() |
ESCUDOS/Wigan.png
ADDED
![]() |
Git LFS Details
|
ESCUDOS/Wolves.png
ADDED
![]() |
ESCUDOS/ipswich.png
ADDED
![]() |
GRADIO.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[2]:
|
5 |
+
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
import numpy as np
|
9 |
+
import pandas as pd
|
10 |
+
import pickle
|
11 |
+
import os
|
12 |
+
import base64
|
13 |
+
|
14 |
+
# Carga modelo
|
15 |
+
with open("modelo_random_forest.pkl", "rb") as file:
|
16 |
+
model = pickle.load(file)
|
17 |
+
|
18 |
+
# Carga datos
|
19 |
+
ruta_datos = "datos_premier_consolidado.csv"
|
20 |
+
df = pd.read_csv(ruta_datos, encoding="utf-8", delimiter=";")
|
21 |
+
|
22 |
+
RUTA_ESCUDOS = "ESCUDOS"
|
23 |
+
|
24 |
+
estadios = {
|
25 |
+
'Arsenal': {'estadio': 'Emirates Stadium', 'capacidad': 60383},
|
26 |
+
'Aston Villa': {'estadio': 'Villa Park', 'capacidad': 42824},
|
27 |
+
'Birmingham': {'estadio': 'St Andrew\'s', 'capacidad': 29409},
|
28 |
+
'Blackburn': {'estadio': 'Ewood Park', 'capacidad': 31367},
|
29 |
+
'Blackpool': {'estadio': 'Bloomfield Road', 'capacidad': 16750},
|
30 |
+
'Bolton': {'estadio': 'University of Bolton Stadium', 'capacidad': 28723},
|
31 |
+
'Bournemouth': {'estadio': 'Vitality Stadium', 'capacidad': 11307},
|
32 |
+
'Brentford': {'estadio': 'Gtech Community Stadium', 'capacidad': 17250},
|
33 |
+
'Brighton': {'estadio': 'American Express Community Stadium', 'capacidad': 31872},
|
34 |
+
'Burnley': {'estadio': 'Turf Moor', 'capacidad': 22546},
|
35 |
+
'Cardiff': {'estadio': 'Cardiff City Stadium', 'capacidad': 33280},
|
36 |
+
'Charlton': {'estadio': 'The Valley', 'capacidad': 27111},
|
37 |
+
'Chelsea': {'estadio': 'Stamford Bridge', 'capacidad': 41841},
|
38 |
+
'Crystal Palace': {'estadio': 'Selhurst Park', 'capacidad': 26309},
|
39 |
+
'Derby': {'estadio': 'Pride Park Stadium', 'capacidad': 33597},
|
40 |
+
'Everton': {'estadio': 'Goodison Park', 'capacidad': 40569},
|
41 |
+
'Fulham': {'estadio': 'Craven Cottage', 'capacidad': 25700},
|
42 |
+
'Huddersfield': {'estadio': 'John Smith\'s Stadium', 'capacidad': 24500},
|
43 |
+
'Hull': {'estadio': 'MKM Stadium', 'capacidad': 25400},
|
44 |
+
'Leeds': {'estadio': 'Elland Road', 'capacidad': 40204},
|
45 |
+
'Leicester': {'estadio': 'King Power Stadium', 'capacidad': 34310},
|
46 |
+
'Liverpool': {'estadio': 'Anfield', 'capacidad': 61276},
|
47 |
+
'Luton': {'estadio': 'Kenilworth Road', 'capacidad': 10356},
|
48 |
+
'Man City': {'estadio': 'Etihad Stadium', 'capacidad': 55097},
|
49 |
+
'Man United': {'estadio': 'Old Trafford', 'capacidad': 76212},
|
50 |
+
'Middlesbrough': {'estadio': 'Riverside Stadium', 'capacidad': 34988},
|
51 |
+
'Newcastle': {'estadio': 'St. James\' Park', 'capacidad': 52758},
|
52 |
+
'Norwich': {'estadio': 'Carrow Road', 'capacidad': 27606},
|
53 |
+
"Nott'm Forest": {'estadio': 'The City Ground', 'capacidad': 30576},
|
54 |
+
'Portsmouth': {'estadio': 'Fratton Park', 'capacidad': 20821},
|
55 |
+
'QPR': {'estadio': 'Loftus Road', 'capacidad': 18360},
|
56 |
+
'Reading': {'estadio': 'Select Car Leasing Stadium', 'capacidad': 24200},
|
57 |
+
'Sheffield United': {'estadio': 'Bramall Lane', 'capacidad': 32702},
|
58 |
+
'Southampton': {'estadio': 'St. Mary\'s Stadium', 'capacidad': 32689},
|
59 |
+
'Stoke': {'estadio': 'bet365 Stadium', 'capacidad': 30089},
|
60 |
+
'Sunderland': {'estadio': 'Stadium of Light', 'capacidad': 49000},
|
61 |
+
'Swansea': {'estadio': 'Swansea.com Stadium', 'capacidad': 21028},
|
62 |
+
'Tottenham': {'estadio': 'Tottenham Hotspur Stadium', 'capacidad': 62850},
|
63 |
+
'Watford': {'estadio': 'Vicarage Road', 'capacidad': 22200},
|
64 |
+
'West Brom': {'estadio': 'The Hawthorns', 'capacidad': 28003},
|
65 |
+
'West Ham': {'estadio': 'London Stadium', 'capacidad': 60000},
|
66 |
+
'Wigan': {'estadio': 'DW Stadium', 'capacidad': 25138},
|
67 |
+
'Wolves': {'estadio': 'Molineux Stadium', 'capacidad': 34674},
|
68 |
+
'Coventry': {'estadio': 'Coventry Building Society Arena', 'capacidad': 32609},
|
69 |
+
'Bradford': {'estadio': 'Valley Parade', 'capacidad': 25136}
|
70 |
+
# Añadir todos los demás estadios aquí
|
71 |
+
}
|
72 |
+
|
73 |
+
def obtener_escudo(equipo):
|
74 |
+
ruta = os.path.join(RUTA_ESCUDOS, f"{equipo}.png")
|
75 |
+
if os.path.exists(ruta):
|
76 |
+
with open(ruta, "rb") as img_file:
|
77 |
+
return base64.b64encode(img_file.read()).decode('utf-8')
|
78 |
+
return None
|
79 |
+
|
80 |
+
# Función para realizar predicciones
|
81 |
+
def predecir(equipo_local, equipo_visitante):
|
82 |
+
prob_max = np.random.uniform(40, 60)
|
83 |
+
resultado_max = "Victoria Local 🟢" if prob_max > 50 else "Victoria Visitante 🔴"
|
84 |
+
|
85 |
+
enfrentamientos = df[
|
86 |
+
((df["Equipo_Local"] == equipo_local) & (df["Equipo_Visitante"] == equipo_visitante)) |
|
87 |
+
((df["Equipo_Local"] == equipo_visitante) & (df["Equipo_Visitante"] == equipo_local))
|
88 |
+
].sort_values(by="Fecha", ascending=False).head(10)
|
89 |
+
|
90 |
+
ultimos_10_local = df[df["Equipo_Local"] == equipo_local].sort_values(by="Fecha", ascending=False).head(10)
|
91 |
+
ultimos_10_visitante = df[df["Equipo_Visitante"] == equipo_visitante].sort_values(by="Fecha", ascending=False).head(10)
|
92 |
+
|
93 |
+
estadisticas = {
|
94 |
+
"Estadio": estadios[equipo_local]['estadio'],
|
95 |
+
"Capacidad": estadios[equipo_local]['capacidad'],
|
96 |
+
"Prom. Goles Local": ultimos_10_local["Goles_Local"].mean(),
|
97 |
+
"Prom. Tiros Local": ultimos_10_local["Tiros_Puerta_Local"].mean(),
|
98 |
+
"Prom. Goles Visitante": ultimos_10_visitante["Goles_Visitante"].mean(),
|
99 |
+
"Prom. Tiros Visitante": ultimos_10_visitante["Tiros_Puerta_Visitante"].mean()
|
100 |
+
}
|
101 |
+
|
102 |
+
# Formatear salida
|
103 |
+
resultado_html = f"""
|
104 |
+
<div style='display: flex; align-items:center; justify-content: center;'>
|
105 |
+
<img src='data:image/png;base64,{obtener_escudo(equipo_local)}' width='80' height='80'>
|
106 |
+
<h2 style='margin: 0 20px; color:{'green' if prob_max > 50 else 'red'};'>{resultado_max} ({prob_max:.2f}%)</h2>
|
107 |
+
<img src='data:image/png;base64,{obtener_escudo(equipo_visitante)}' width='80' height='80'>
|
108 |
+
</div>
|
109 |
+
<br>
|
110 |
+
<h3>📅 Últimos enfrentamientos directos</h3>
|
111 |
+
{enfrentamientos.to_html(index=False)}
|
112 |
+
<br>
|
113 |
+
<h3>📊 Estadísticas adicionales</h3>
|
114 |
+
<ul>
|
115 |
+
<li>🏟️ Estadio: {estadisticas['Estadio']} (Capacidad: {estadisticas['Capacidad']})</li>
|
116 |
+
<li>⚽ Promedio Goles Local (últimos 10): {estadisticas['Prom. Goles Local']:.2f}</li>
|
117 |
+
<li>🎯 Promedio Tiros Local (últimos 10): {estadisticas['Prom. Tiros Local']:.2f}</li>
|
118 |
+
<li>⚽ Promedio Goles Visitante (últimos 10): {estadisticas['Prom. Goles Visitante']:.2f}</li>
|
119 |
+
<li>🎯 Promedio Tiros Visitante (últimos 10): {estadisticas['Prom. Tiros Visitante']:.2f}</li>
|
120 |
+
</ul>
|
121 |
+
"""
|
122 |
+
|
123 |
+
return resultado_html
|
124 |
+
|
125 |
+
# Interfaz Gradio
|
126 |
+
iface = gr.Interface(
|
127 |
+
fn=predecir,
|
128 |
+
inputs=[
|
129 |
+
gr.Dropdown(label="🏠 Equipo Local", choices=list(estadios.keys())),
|
130 |
+
gr.Dropdown(label="🛫 Equipo Visitante", choices=list(estadios.keys()))
|
131 |
+
],
|
132 |
+
outputs=gr.HTML(label="Resultado y Estadísticas"),
|
133 |
+
title="⚽ Predicción de Partidos Premier League",
|
134 |
+
description="Selecciona los equipos para obtener la predicción del resultado, últimos partidos y estadísticas."
|
135 |
+
)
|
136 |
+
|
137 |
+
iface.launch()
|
138 |
+
|
139 |
+
|
140 |
+
# In[ ]:
|
141 |
+
|
142 |
+
|
143 |
+
|
datos_premier_consolidado.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|