football-tda | The shape of football games
kandi X-RAY | football-tda Summary
kandi X-RAY | football-tda Summary
The purpose of this project is to show a possible application of TDA. Our use case is based on football and the goal (pun intended) is to try to forecast the outcome of a match. You can find our blog post at this link.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Cross validation
- Construct a dictionary of model parameters
- Validate k - fold model
- Generate a power set from an iterable
- Compute final standings
- Generate a random number of players
- Calculates the player s averages
- Print the ranking of the candidates
- Attempts to hire a league
- Add stats to a DataFrame
- Insert players into match table
- Replace a single player with a new one
- Switch player by name
- Switch to player id
- Extract the features for each prediction
- Gets the best model for the best model
football-tda Key Features
football-tda Examples and Code Snippets
Community Discussions
Trending Discussions on football-tda
QUESTION
I'm trying to reproduce this GitHub project on my machine, on Topological Data Analysis (TDA).
My steps:
- get best parameters from a cross-validation output
- load my dataset feature selection
- extract topological features from the dataset for prediction
- create a Random Forest Classifier model built on the best parameters
- calculate probabilities on test data
Background:
- Feature selection
In order to decide which attributes belong to which group, we created a correlation matrix. From this, we saw that there were two big groups, where player attributes were strongly correlated with each other. Therefore, we decided to split the attributes into two groups, one to summarise the attacking characteristics of a player while the other one the defensiveness. Finally, since the goalkeeper has completely different statistics with respect to the other players, we decided to take into account only the overall rating. Below, is possible to see the 24 features used for each player:
Attack: "positioning", "crossing", "finishing", "heading_accuracy", "short_passing", "reactions", "volleys", "dribbling", "curve", "free_kick_accuracy", "acceleration", "sprint_speed", "agility", "penalties", "vision", "shot_power", "long_shots" Defense: "interceptions", "aggression", "marking", "standing_tackle", "sliding_tackle", "long_passing" Goalkeeper: "overall_rating"
From this set of features, the next step we did was to, for each non-goalkeeper player, compute the mean of the attack attributes and the defensive ones.
Finally, for each team in a given match, we compute the mean and the standard deviation for the attack and the defense from these stats of the team's players, as well as the best attack and best defense.
In this way a match is described by 14 features (GK overall value, best attack, std attack, mean attack, the best defense, std defense, mean defense), that mapped the match in the space, following the characterizes of the two teams.
- Feature extraction
The aim of TDA is to catch the structure of the space underlying the data. In our project, we assume that the neighborhood of a data point hides meaningful information that is correlated with the outcome of the match. Thus, we explored the data space looking for this kind of correlation.
Methods:
...ANSWER
Answered 2021-Jan-16 at 01:36The answer is actually given in the question already.
You mentioned in your question, # x_test.shape -> (380, 24)
and # x_train.shape -> (2565, 19)
. As it is very clear and can be seen that your test data shape doesn't match with your train data, your train data have 19
features, whereas the test data have got 24
features (they must contain same amount of feature) thus you're getting the error "X has 24 features, but DecisionTreeClassifier is expecting 19 features as input"
when you're giving the x_test
inside your model in this line - get_probabilities(rf_model, x_test, team_ids)
.
So, your test data must have 24 features just like your train data.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install football-tda
You can use football-tda like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page