File size: 1,597 Bytes
c40ab65
 
 
 
 
 
 
 
 
17cd02a
c40ab65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import numpy as np
import pandas as pd
from scipy.stats import poisson
import tools
import streamlit as st
import matplotlib.pyplot as plt
import seaborn as sns

# Lendo arquivo excel
df = pd.read_excel('info_futebol.xlsx', sheet_name='info_geral', index_col='Time')

# Criando coluna de força de times
a, b = df['Pontuacao'].min(), df['Pontuacao'].max()
fa, fb = 0.15, 1 # novos limites
b1 = (fb - fa)/(b-a)
b0 = fb - b*b1
df['forca'] = round(b0 + b1*df['Pontuacao'], 3)

# Streamlit Step

rad = st.sidebar.radio('Navegue pelos itens', ['Home', 'Sobre', 'BET Jogos', 'BET Campeonato'])

if rad == 'Home':
	st.markdown(""" ##  :soccer: BET-POISSON """)
	st.write('Simulando jogos com base na distribuição de Poisson.')

if rad == 'Sobre':
	st.write('Em construção')

if rad == 'BET Jogos':
	times1 = list(df.index)
	times2 = times1.copy()
	casa, visitante = st.columns(2)
	time1 = casa.selectbox('Time Casa', times1)
	times2.remove(time1)
	time2 = visitante.selectbox('Time Visitante', times2)
	prob, matrix = tools.probabilidades_partidas(df, time1, time2)


	col1, col2, col3, col4, col5 = st.columns(5)
	col1.image(df.loc[time1, 'imagem'])  
	col2.metric(time1, prob[0])
	col3.metric('Empate', prob[1])
	col4.metric(time2, prob[2]) 
	col5.image(df.loc[time2, 'imagem'])

	if st.button('Mostrar mapa de calor dos placares'):
		fig, ax = plt.subplots(figsize=(10, 5))
		sns.heatmap(matrix, vmax = 19 , annot=True, linewidth = .5, fmt=".1f")
		plt.xlabel(f'{time2}', fontsize=13)
		plt.ylabel(f'{time1}', fontsize=13)
		st.pyplot(fig)

if rad == 'BET Campeonato':
	st.write('Em construção')