FERNANDITOVALERO commited on
Commit
de56a30
·
verified ·
1 Parent(s): dd6d0af

Upload 51 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.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

  • SHA256: 28a1c0622305c76b79e7622097eafd9b198e9138ddbedb8aab03535b07fb9456
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
ESCUDOS/Aston Villa.png ADDED

Git LFS Details

  • SHA256: d19c20963fdfa380bdc8347ea75e35d8e2cb9f765b0210ccf1b58312d3fd3544
  • Pointer size: 131 Bytes
  • Size of remote file: 138 kB
ESCUDOS/Birmingham.png ADDED

Git LFS Details

  • SHA256: d0b9cd8779f9ddce1a4b853a0e60ca855f2bcb27368b47dd076085105626064e
  • Pointer size: 131 Bytes
  • Size of remote file: 125 kB
ESCUDOS/Blackburn.png ADDED

Git LFS Details

  • SHA256: 2f46231febd09c19e332ed927f38c154da6662868883936bd995144a37664ad4
  • Pointer size: 131 Bytes
  • Size of remote file: 161 kB
ESCUDOS/Blackpool.png ADDED

Git LFS Details

  • SHA256: 4e9c310ddef9a1c90f53fd485c5844ebc58f2addce751b2b46b2da2876b5b247
  • Pointer size: 131 Bytes
  • Size of remote file: 125 kB
ESCUDOS/Bolton.png ADDED
ESCUDOS/Bournemouth.png ADDED
ESCUDOS/Bradford.png ADDED

Git LFS Details

  • SHA256: 4a79efee2c52ce2d1c1cb2d12cb97f817aefbc5f50b40dd873f0687d7b24814a
  • Pointer size: 131 Bytes
  • Size of remote file: 171 kB
ESCUDOS/Brentford.png ADDED

Git LFS Details

  • SHA256: 0b34aea58174efa18ee2028de087d0f901af1e4004ad2d0cfccb9bf0507ed7e9
  • Pointer size: 131 Bytes
  • Size of remote file: 127 kB
ESCUDOS/Brighton.png ADDED
ESCUDOS/Burnley.png ADDED
ESCUDOS/Cardiff.png ADDED

Git LFS Details

  • SHA256: e213f432a290574eff911f9136ee5b4218bc3e56594cfd24726079418f57e532
  • Pointer size: 131 Bytes
  • Size of remote file: 139 kB
ESCUDOS/Charlton.png ADDED

Git LFS Details

  • SHA256: 900b9b481dec3dc30d4f63e9f985d13296bf2323ad02ddfb3e881db49ea99278
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
ESCUDOS/Chelsea.png ADDED

Git LFS Details

  • SHA256: 6e90bf60d8912613c6df263645f002953f45542ed7cdaccc7805c65f4216f6bc
  • Pointer size: 131 Bytes
  • Size of remote file: 154 kB
ESCUDOS/Coventry.png ADDED

Git LFS Details

  • SHA256: 914a0242608715cb971275fe5a6bfdfdc2a882d89302a99957364dac29d986f4
  • Pointer size: 131 Bytes
  • Size of remote file: 435 kB
ESCUDOS/Crystal Palace.png ADDED
ESCUDOS/Derby.png ADDED

Git LFS Details

  • SHA256: a7264c5b88f9c9cde438c0a09c3f3436a4b6867e70aa1545df4a2dbb00f66e3f
  • Pointer size: 131 Bytes
  • Size of remote file: 240 kB
ESCUDOS/Everton.png ADDED

Git LFS Details

  • SHA256: f84d513ee2d91524c3ebae810a69a09e0322fe6790915ab18aebb3d5faafeae9
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
ESCUDOS/Fulham.png ADDED
ESCUDOS/Huddersfield.png ADDED

Git LFS Details

  • SHA256: cface99b761f54b3045be6c96236dc6f9f48e827ba9bf37b37fdb37c604b4ba2
  • Pointer size: 131 Bytes
  • Size of remote file: 220 kB
ESCUDOS/Hull.png ADDED

Git LFS Details

  • SHA256: 7cc287d1935bc377dfea06053947d43ec9e7eecd69fdc4f7ecf7a59418a1b063
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
ESCUDOS/Leeds.png ADDED
ESCUDOS/Leicester.png ADDED

Git LFS Details

  • SHA256: 3569a949ba033b75c7a19a8c434b27eb27e71a46e43d967578fefc412066b51a
  • Pointer size: 131 Bytes
  • Size of remote file: 139 kB
ESCUDOS/Liverpool.png ADDED

Git LFS Details

  • SHA256: 74ce712e85f3d2be54ae183125a9861dc7163f3215dd8c5a1a55279cf2d25bc3
  • Pointer size: 131 Bytes
  • Size of remote file: 302 kB
ESCUDOS/Luton.png ADDED

Git LFS Details

  • SHA256: bb75ec38369aafbc0819e4bb4f599aa89c5dcfedae063765e3ca0557f66bcd1e
  • Pointer size: 131 Bytes
  • Size of remote file: 139 kB
ESCUDOS/Man City.png ADDED

Git LFS Details

  • SHA256: 764ba3026696bf48b2ae6d6ef13f125ed9cfc1fa4e2c7a9b9512669ecd44628f
  • Pointer size: 131 Bytes
  • Size of remote file: 155 kB
ESCUDOS/Man United.png ADDED

Git LFS Details

  • SHA256: 7607329dc93c794bfa5166b08e4102df4618652261b49549bb1c187c0e385249
  • Pointer size: 131 Bytes
  • Size of remote file: 301 kB
ESCUDOS/Middlesbrough.png ADDED

Git LFS Details

  • SHA256: f335f2344fd14900e216862f55d510cf242d0ad4d2269a01a3e5c08745df370a
  • Pointer size: 131 Bytes
  • Size of remote file: 226 kB
ESCUDOS/Newcastle.png ADDED

Git LFS Details

  • SHA256: 2c32e2f6e42fd3b78a539078d82737a7c9fe6dc348b778b5af24e359bff06c09
  • Pointer size: 131 Bytes
  • Size of remote file: 176 kB
ESCUDOS/Norwich.png ADDED
ESCUDOS/Nott'm Forest.png ADDED
ESCUDOS/PREMIER.png ADDED
ESCUDOS/Portsmouth.png ADDED

Git LFS Details

  • SHA256: d5643fa028e369b1838d8f3256952bcc46cf39eaa020fca3b4b5d3d82f4104a4
  • Pointer size: 131 Bytes
  • Size of remote file: 128 kB
ESCUDOS/QPR.png ADDED

Git LFS Details

  • SHA256: e24f5e65299eb048c892c2c6fc4b826af4458cde37bee97b911939aec2ea0083
  • Pointer size: 131 Bytes
  • Size of remote file: 234 kB
ESCUDOS/Reading.png ADDED

Git LFS Details

  • SHA256: 5af2d9fd5b440fb58df940f67e184ca8d287a45329aa7fc0be0c8965f02551e0
  • Pointer size: 131 Bytes
  • Size of remote file: 274 kB
ESCUDOS/Sheffield United.png ADDED

Git LFS Details

  • SHA256: 03f85de11acc5dd15419ab563bd912e0ff6909c76ce0f7d79c601f5933f45686
  • Pointer size: 131 Bytes
  • Size of remote file: 161 kB
ESCUDOS/Southampton.png ADDED

Git LFS Details

  • SHA256: df23cb65ef35afec323b9055b130d943a773287a0d648a3f94671fc5c34300e5
  • Pointer size: 131 Bytes
  • Size of remote file: 121 kB
ESCUDOS/Stoke.png ADDED
ESCUDOS/Sunderland.png ADDED

Git LFS Details

  • SHA256: b4aa97dc2d5c0f42d2abc86945acd484217200762d4ee28eb8c6a6d4bed77760
  • Pointer size: 131 Bytes
  • Size of remote file: 181 kB
ESCUDOS/Swansea.png ADDED
ESCUDOS/Tottenham.png ADDED
ESCUDOS/Watford.png ADDED
ESCUDOS/West Brom.png ADDED

Git LFS Details

  • SHA256: bd3dfa6d4fd47a7b77b5c2c8543c18910c2290d060d79fc0e5ebcbb13d576a52
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
ESCUDOS/West Ham.png ADDED
ESCUDOS/Wigan.png ADDED

Git LFS Details

  • SHA256: 4faf7efe3dd4cecc86570889027e6775686d4f89d3957cac5546cf17cc27be62
  • Pointer size: 131 Bytes
  • Size of remote file: 520 kB
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