kad568 / fpl

0 stars 0 forks source link

fixture difficulty tool #3

Open kad568 opened 1 month ago

kad568 commented 1 month ago

what makes a team hard to play?

kad568 commented 1 month ago

old fpl json has defensive and offensive ratings

kad568 commented 1 month ago

use seaborn for plotting heatmaps

kad568 commented 1 month ago

image

kad568 commented 1 month ago

maybe sort by avg heat rating

kad568 commented 1 month ago

To rank a Seaborn heatmap by average heat, you want to reorder the rows or columns based on the average value of the heatmap's data. This involves calculating the average for each row or column and then sorting accordingly. Here's a general approach using Python and Seaborn:

  1. Calculate Averages: Compute the average value for each row or column of your heatmap data.
  2. Sort Data: Sort the rows or columns based on these averages.
  3. Reorder Heatmap: Use the sorted indices to reorder your data in the heatmap.

Here's a step-by-step code example:

import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Sample data for illustration
data = np.random.rand(10, 10)  # 10x10 matrix with random values
df = pd.DataFrame(data, columns=[f'Col{i}' for i in range(1, 11)], index=[f'Row{i}' for i in range(1, 11)])

# Calculate the average heat for each row
row_averages = df.mean(axis=1)

# Get the order of rows based on the average heat (from highest to lowest)
row_order = row_averages.sort_values(ascending=False).index

# Reorder the DataFrame based on this order
df_ordered = df.loc[row_order]

# Create the heatmap with reordered rows
sns.heatmap(df_ordered, cmap='viridis', annot=True)
plt.title('Heatmap Ordered by Average Heat')
plt.show()

Explanation:

Note: If you want to rank by column averages instead, switch axis=1 to axis=0 when calculating the averages and sort the columns instead of the rows.

kad568 commented 1 month ago

i need a stat to compare performance, so i can corelate team strength effects on opposition:

performance could mean xg made, xg conceded, xg difference, g for and against difference

do a scatter plot to get an average effect strength differences has so 50% decrease when vs city for example

kad568 commented 1 month ago

image

imrpoved

kad568 commented 1 month ago

image

weird, the away strength is high in all cases, which does not match intuition

kad568 commented 1 month ago
kad568 commented 1 month ago

maybe an issue on my end

kad568 commented 1 month ago

the actual team starts are in json files hosted online, see:

kad568 commented 1 month ago

maybe the same for player.

use these links instead

kad568 commented 1 month ago

got data

image