Complete guide for training the FIFA Player Recommendation System models.
Train both models with one command:
python training/train.py
That’s it! Both models will be trained and saved to the models/ directory.
python training/train.py
Trains both male and female player models.
Output:
models/male_model.pkl (~1 GB)models/female_model.pkl (~10 MB)Time: ~30-35 seconds total
python training/train.py --male
Use case: When you only need male player recommendations.
python training/train.py --female
Use case: When you only need female player recommendations.
# Train female only (skip male)
python training/train.py --skip-male
# Train male only (skip female)
python training/train.py --skip-female
new-data/Example output when training both models:
======================================================================
⚽ FIFA Player Recommendation System - Model Training
======================================================================
Models to train:
• Male Players Model
• Female Players Model
======================================================================
🔵 Training Male Players Model
======================================================================
[📊] Processing Male Players data...
✓ Loaded 16163 players
✓ Extracted 34 features
✓ Feature matrix shape: (16163, 34)
[🤖] Training Male Players model...
Computing similarity matrix...
Similarity matrix computed: (16163, 16163)
✓ Similarity matrix computed: (16163, 16163)
[💾] Saving Male Players model...
Model saved to models/male_model.pkl
✓ Model saved: models/male_model.pkl
✓ File size: 1007.2 MB
[🧪] Testing Male Players model...
✓ Top player: Kylian Mbappé
✓ Search test: Found 5 players
✓ Recommendation test: 3 similar players found
✅ Male Players model trained successfully in 28.3s
======================================================================
🟣 Training Female Players Model
======================================================================
[📊] Processing Female Players data...
✓ Loaded 1578 players
✓ Extracted 34 features
✓ Feature matrix shape: (1578, 34)
[🤖] Training Female Players model...
Computing similarity matrix...
Similarity matrix computed: (1578, 1578)
✓ Similarity matrix computed: (1578, 1578)
[💾] Saving Female Players model...
Model saved to models/female_model.pkl
✓ Model saved: models/female_model.pkl
✓ File size: 9.6 MB
[🧪] Testing Female Players model...
✓ Top player: Aitana Bonmatí
✓ Search test: Found 5 players
✓ Recommendation test: 3 similar players found
✅ Female Players model trained successfully in 1.9s
======================================================================
📊 Training Summary
======================================================================
Models trained:
✅ Male Players Model - 28.3s
✅ Female Players Model - 1.9s
Total training time: 30.2s
✨ You can now run the application:
python run.py
Or:
cd app && python main.py
======================================================================
Cause: CSV files are missing or in wrong location
Solution:
# Check if files exist
ls new-data/
# Should show: male_players.csv, female_players.csv
# If missing, ensure you're in the project root directory
cd FIFA-Player-Recomendation
Cause: Insufficient RAM (especially for male model)
Solutions:
python training/train.py --femaleCause: Dependencies not installed
Solution:
pip install -r requirements.txt
Normal behavior:
If significantly slower:
This is expected:
Why so large?
import sys
import os
sys.path.insert(0, os.path.abspath('.'))
from src.data_processing import DataProcessor
from src.model import PlayerRecommender
# Process data
processor = DataProcessor()
processed = processor.process_for_training('new-data/male_players.csv')
# Train model
model = PlayerRecommender()
model.fit(
data=processed['data'],
normalized_features=processed['normalized_features'],
feature_names=processed['feature_names']
)
# Save model
model.save('models/male_model.pkl')
# Use model
recommendations = model.recommend_similar('Kylian Mbappé', n_recommendations=10)
print(f"Found {len(recommendations)} similar players")
For automated training in CI/CD pipelines:
# Non-interactive mode
python training/train.py > training.log 2>&1
# Check exit code
if [ $? -eq 0 ]; then
echo "Training successful"
else
echo "Training failed"
exit 1
fi
# Clone repository
!git clone https://github.com/inboxpraveen/FIFA-Player-Recomendation.git
%cd FIFA-Player-Recomendation
# Install dependencies
!pip install -r requirements.txt
# Train models
!python training/train.py
# Download trained models
from google.colab import files
files.download('models/male_model.pkl')
files.download('models/female_model.pkl')
# SSH into instance
ssh -i key.pem ubuntu@ec2-instance
# Clone and train
git clone https://github.com/inboxpraveen/FIFA-Player-Recomendation.git
cd FIFA-Player-Recomendation
pip install -r requirements.txt
python training/train.py
The system uses content-based filtering with cosine similarity:
similarity(A, B) = (A · B) / (||A|| × ||B||)
Advantages:
Result: < 50ms recommendations instead of ~500ms
# Simply run the training script again
python training/train.py
# Old models will be overwritten
After training, verify models exist and work:
# Check files
ls -lh models/
# Should show: male_model.pkl (~1GB), female_model.pkl (~10MB)
# Test models by running the app
python run.py
# Access in browser
# http://localhost:5000
ls models/python run.pyIssues during training?
pip install -r requirements.txtStill stuck? Open a new issue with:
Made with ⚽ by Praveen Kumar