Skip to content

Repository files navigation

FIFA Player Similarity Engine

A machine learning clustering model that identifies like-for-like player replacements using FIFA 19 data. Built with K-means clustering on 34 player attributes, this tool helps scouts, analysts, and football enthusiasts find statistically similar players based on playing style, technical abilities, and market value.

🎯 Features

  • K-means Clustering: 9 distinct player clusters based on playing style and position
  • Position-Based Grouping: Players categorized into Forwards (F), Midfielders (M), Defenders (D), and Goalkeepers (GK)
  • Value-Based Filtering: Find replacements within a specified budget range
  • 34 Attribute Analysis: Comprehensive evaluation including technical skills (crossing, finishing, dribbling), physical attributes (pace, strength, stamina), and mental traits (composure, vision)
  • Data-Driven Recommendations: Over 18,000 FIFA 19 players analyzed

📊 How It Works

The model uses K-means clustering with the following process:

  1. Data Processing: Cleans FIFA 19 dataset and handles missing values
  2. Feature Extraction: Uses 34 player attributes (Crossing through GKReflexes)
  3. Standardization: Scales all features using sklearn preprocessing
  4. Optimal Clustering: Elbow method and Silhouette analysis determine 9 as optimal cluster count
  5. Position Classification: Simplifies 27 positions into 4 main groups (F/M/D/GK)
  6. Value Conversion: Processes market values from FIFA format (e.g., "€37.5M") to numeric

🚀 Getting Started

Prerequisites

Python 3.7+
numpy
pandas
matplotlib
seaborn
scikit-learn
scipy

Installation

# Clone the repository
git clone https://github.com/chakradhaarrv/fifa-player-similarity.git
cd fifa-player-similarity

# Install dependencies
pip install -r requirements.txt

Quick Start

import pandas as pd
from sklearn.cluster import KMeans
import sklearn.preprocessing as preprocessing

# Load and preprocess data
data = pd.read_csv('fifa19data.csv')

# Select attribute columns (Crossing through GKReflexes)
attributes = data.iloc[:, 54:88]

# Standardize features
scaled_data = preprocessing.scale(attributes, axis=0)

# Apply K-means clustering
kmeans = KMeans(n_clusters=9, random_state=200)
clusters = kmeans.fit_predict(scaled_data)

# Find similar players
def find_similar_players(player_name, value_range=0.1, num_results=20):
    """
    Find similar players based on cluster and market value
    
    Parameters:
    - player_name: Name of the player to find replacements for
    - value_range: Percentage range for value filtering (default 10%)
    - num_results: Number of results to return
    """
    cluster = data.loc[data["Name"] == player_name, "Cluster"].iloc[0]
    value = data.loc[data["Name"] == player_name, "Value in Pounds"].iloc[0]
    
    similar = data[
        (data["Cluster"] == cluster) & 
        (data["Value in Pounds"] >= value * (1 - value_range)) &
        (data["Value in Pounds"] <= value * (1 + value_range))
    ]
    
    return similar.head(num_results)

# Example usage
similar_players = find_similar_players("I. Perišić", value_range=0.1, num_results=20)
print(similar_players[["Name", "Club", "Overall", "Value"]])

📁 Project Structure

fifa-player-similarity/
├── fifa19_clustering.ipynb    # Main clustering analysis and player recommendation system
├── fifa19data.csv             # FIFA 19 dataset (18,000+ players)
├── README.md                  # Project documentation
├── requirements.txt           # Python dependencies
└── Additional Analysis/
    ├── Analysis.ipynb         # Extended statistical analysis
    └── FIFA 19 Visualizations.ipynb  # Data visualization and exploratory analysis

🔍 Cluster Analysis

The model identifies 9 distinct clusters with the following position distributions:

Cluster Primary Position Description
0 Defenders (1,250) Defensive-minded fullbacks and center backs
1 Goalkeepers (2,025) All goalkeeper types
2 Attackers (527) & Midfielders (1,744) Attacking midfielders and forwards
3 Defenders (1,541) Traditional center backs
4 Defenders (1,197) & Midfielders (1,716) Defensive midfielders and versatile defenders
5 Defenders (1,338) Strong, physical defenders
6 Defenders (524) & Midfielders (1,337) Box-to-box midfielders and wing-backs
7 Forwards (1,408) Clinical strikers and attackers
8 Midfielders (1,557) & Forwards (655) Attacking wingers and inside forwards

📊 Model Performance

  • Optimal Clusters: Determined using Elbow Method and Silhouette Analysis
  • Silhouette Score (k=9): 0.185
  • Features Used: 34 player attributes
  • Dataset Size: 18,159 players after cleaning

📊 Sample Results

Finding replacements for Ivan Perišić (Cluster 6, €37.5M):

Player Club Overall Position Value
Jordi Alba FC Barcelona 87 D €38M
J. Vertonghen Tottenham Hotspur 87 D €34M
Piqué FC Barcelona 87 D €34M
J. Kimmich FC Bayern München 85 M €40.5M
Diego Costa Atlético Madrid 85 F €38.5M

📈 Key Features

Attribute Categories Analyzed:

  • Technical: Crossing, Finishing, Heading Accuracy, Short Passing, Volleys, Dribbling, Curve, FK Accuracy, Long Passing, Ball Control
  • Physical: Acceleration, Sprint Speed, Agility, Reactions, Balance, Jumping, Stamina, Strength
  • Mental: Shot Power, Positioning, Vision, Penalties, Composure, Long Shots, Aggression, Interceptions
  • Defensive: Marking, Standing Tackle, Sliding Tackle
  • Goalkeeping: GK Diving, Handling, Kicking, Positioning, Reflexes

🔧 Data Processing

The notebook includes comprehensive preprocessing:

  • Removal of incomplete records (48 players with missing GK attributes)
  • Currency conversion (€M/K format → numeric)
  • Position simplification (27 positions → 4 groups)
  • Skill rating conversion for positional versatility
  • Feature standardization using sklearn

🎓 Methodology

Clustering Approach

  1. Elbow Method: Tested k=1 to k=19 to find optimal cluster count
  2. Silhouette Analysis: Validated cluster quality (k=7 to k=12)
  3. Final Selection: 9 clusters based on balance of homogeneity and separation

Position Grouping Logic

F (Forwards): ST, CF, RF, LF, RS, LS
M (Midfielders): CAM, CM, CDM, LM, RM, LAM, RAM, LCM, RCM, LDM, RDM, LW, RW
D (Defenders): CB, LB, RB, LCB, RCB, LWB, RWB
GK (Goalkeepers): GK

🤝 Contributing

Contributions are welcome! Areas for improvement:

  • Add more recent FIFA datasets (FIFA 20-24)
  • Implement additional clustering algorithms (DBSCAN, hierarchical)
  • Create interactive web interface
  • Add player form and injury data
  • Implement tactical fit scoring

Please feel free to submit a Pull Request or open an issue for discussion.

🙏 Acknowledgments

  • FIFA 19 dataset from EA Sports
  • Built with scikit-learn, pandas, and matplotlib
  • Inspired by modern football analytics and scouting methodologies

📧 Contact

For questions or feedback, please open an issue on GitHub.


Note: This analysis uses FIFA 19 game data for educational and analytical purposes. Player ratings and attributes are based on EA Sports' proprietary system and may not reflect real-world performance in all cases.

Releases

Packages

Contributors

Languages