Pycaret vs Catboost: Predicting Soccer Match Outcomes
Soccer is the world‘s most popular sport, captivating billions of fans globally. With so much passion and money involved, there is immense interest in predicting the outcomes of matches. Accurate predictions are valuable for betting markets, club decision-making, and satisfying the curiosity of fans.
Machine learning offers powerful tools for predicting soccer match results based on historical data and relevant variables. In this post, we‘ll use the Soccer Fever dataset to compare two leading ML libraries – Pycaret and Catboost – and see which can deliver superior predictive performance.
The Power of Pycaret
Pycaret is a popular open-source machine learning library in Python that allows you to go from preparing your data to deploying your model within seconds. It is an end-to-end machine learning and model management tool that exponentially speeds up the experiment cycle and makes you more productive.
Some of the key features and advantages of Pycaret include:
-
Simplicity: Pycaret is extremely simple and easy to use. All the steps performed in a ML experiment can be executed using few lines of code.
-
Productivity: With Pycaret, you spend less time coding and more time on analysis and insights. It automates a lot of the repetitive tasks.
-
Wide range of ML tasks: Pycaret can be used for a wide array of machine learning tasks including classification, regression, clustering, anomaly detection, NLP and more.
-
Model comparison: One of the best things about Pycaret is that it allows you to compare the performance of multiple ML algorithms with a single line of code. This makes model selection much easier.
-
Model tuning: Pycaret also has built-in automated hyperparameter tuning to optimize model performance.
Catboost: Gradient Boosted Decision Trees
Catboost is an open-source gradient boosting on decision trees (GBDT) library developed by Yandex. It provides state-of-the-art implementations of the GBDT algorithm and its variations.
Some of the key advantages of Catboost are:
-
Performance: Catboost provides best-in-class performance on many ML tasks out of the box. It dominates many Kaggle competitions.
-
Handling categorical features: A key differentiator of Catboost is its superior ability to handle categorical features automatically. It converts categorical features to numerical features using various statistics on combinations of categorical features.
-
Speed: Catboost trains models very quickly due to its well optimized code base. For large datasets, you can take advantage of multi-GPU training.
-
Reduced overfitting: Catboost implements robust safeguards against overfitting including a novel gradient-based one-hot-encoding for categorical features.
-
Easy to use: While very powerful, the Catboost API is straightforward to use. You can usually get very good results with default parameters.
The Soccer Fever Dataset
Now that we understand the capabilities of Pycaret and Catboost, let‘s dive into the dataset we‘ll be working with. The Soccer Fever dataset contains data on over 42,000 soccer matches across various leagues and seasons.
The dataset contains the following variables:
- Season: The season the match was played
- Date: The date of the match
- League_id: ID of the league the match belongs to
- League: Name of the league
- Team 1/2: The two teams playing the match
- SPI1/2: Soccer Power Index rating of the two teams, which indicates team strength
- Proj_score1/2: Projected number of goals scored by each team
- Importance1/2: A rating of how important the match is for each team
- Score1/2: Actual number of goals scored by each team
- xg1/2: Expected goals scored by each team based on quality of chances created
- nsxg1/2: Expected non-shot expected goals, chances that didn‘t result in a shot
- adj_score1/2: Goals scored adjusted for opposition strength
- Outcome: Which team won (0=team 2 win, 1=team 1 win)
The goal is to build a binary classification model that predicts the match outcome (which team will win) based on the other variables. We‘ll build models using both Pycaret and Catboost and compare their predictive performance.
Modeling with Pycaret
Let‘s start by building a classification model with Pycaret. The first step is to import the required libraries and read in the data:
from pycaret.classification import *
import pandas as pd
train = pd.read_csv(‘train.csv‘)
test = pd.read_csv(‘test.csv‘)
Next, we set up the Pycaret experiment:
exp = setup(data = train,
target = ‘Outcome‘,
feature_selection = True,
normalize = True,
transformation = True,
remove_multicollinearity = True,
multicollinearity_threshold = 0.95)
Here we specify the target variable, enable some automated preprocessing like feature selection, normalization, and removing correlated features.
Now we can compare different classifier algorithms:
best = compare_models()
This will train and evaluate multiple classification algorithms and rank them by performance. We find that the Light Gradient Boosting Machine (LGBM) classifier performs best with around 60% accuracy.
We can then create and evaluate an LGBM model:
lgbm = create_model(‘lightgbm‘)
Pycaret makes it very easy to tune the hyperparameters of the model:
tuned_lgbm = tune_model(lgbm)
After finding the optimal hyperparameters, we can use the predict_model function to get predictions on the test set:
predictions = predict_model(tuned_lgbm, data=test)
Finally, we can save the trained model:
save_model(tuned_lgbm, ‘lgbm_model‘)
This Pycaret model building process is very straightforward and requires minimal code. In a short time, we are able to build a fairly performant classification model.
Modeling with Catboost
Now let‘s see how Catboost compares. First we need to install the Catboost library and import it along with some helper libraries:
!pip install catboost
from catboost import CatBoostClassifier, Pool
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
Next, we separate our features and target variable:
features = [‘season‘, ‘league_id‘, ‘Team 1‘, ‘Team2‘, ‘SPI1‘, ‘SPI2‘,
‘proj_score1‘, ‘proj_score2‘]
categorical_features = [‘league_id‘, ‘Team 1‘, ‘Team2‘]
X = train[features]
y = train[‘Outcome‘]
Note that we specify the categorical features that Catboost will handle. We then split our data into train and validation sets:
X_train, X_validation, y_train, y_validation = train_test_split(X, y, train_size=0.8, random_state=1234)
Initialize Catboost classifier with some parameters:
model = CatBoostClassifier(iterations=1000,
learning_rate=0.05,
random_seed=1234,
eval_metric=‘Logloss‘,
use_best_model=True,
task_type="GPU")
Here we specify the number of iterations, learning rate, evaluation metric and that we want to use the best model. We also specify to train on GPU for speed.
We then fit the model:
model.fit(X_train, y_train,
cat_features=categorical_features,
eval_set=(X_validation, y_validation),
verbose=False)
This will train the Catboost model and use the validation set for early stopping. We can then evaluate the model‘s accuracy:
preds = model.predict(X_validation)
print(‘Validation Accuracy:‘, accuracy_score(y_validation, preds))
The Catboost model achieves a validation accuracy of around 68%, outperforming the Pycaret LGBM model.
To get predictions on the test set:
test_preds = model.predict_proba(test[features])
Comparing Pycaret and Catboost
Both Pycaret and Catboost were able to build solid classification models for predicting soccer match outcomes. However, the Catboost model outperformed the Pycaret LGBM model in terms of accuracy by about 8 percentage points (68% vs 60%).
A key advantage of Catboost was its ability to automatically handle the categorical team name and league ID features without the need for manual encoding. The Catboost model training code was a bit more verbose than with Pycaret, but not overly complex.
Pycaret, on the other hand, made it extremely easy to preprocess the data, compare multiple models, and tune hyperparameters with very minimal code. This ease of use is a major benefit, even if the resulting model was not quite as accurate as Catboost.
Feature Importance Insights
In addition to the model results, it‘s useful to examine which features had the biggest impact on predictions. We can visualize feature importance for the Catboost model:
feature_importances = model.get_feature_importance(Pool(X_validation, y_validation, cat_features=categorical_features))
plt.figure(figsize=(10, 10))
plt.barh(np.array(features)[np.argsort(feature_importances)], np.sort(feature_importances))
plt.title(‘Catboost Feature Importance‘);

We see that the Soccer Power Index (SPI) ratings of the teams are by far the most important predictors, followed by the projected goal totals. The league ID categorical feature also has some importance. This gives us insight into what drives the outcomes and where to focus for extracting the most signal.
Improving Performance Further
While we achieved solid results with both Pycaret and Catboost, there are a number of techniques we could explore to boost performance further:
-
Ensembling: Combining the predictions of multiple diverse models often performs better than any single model. We could ensemble the Pycaret and Catboost models, perhaps with other algorithms as well.
-
More feature engineering: We could derive additional features like the difference in SPI ratings, recent win/loss streaks of teams, head-to-head history, etc. Creative feature engineering is often the key to squeezing out more performance.
-
Hyperparameter tuning: While we did some light hyperparameter tuning, a more exhaustive search using techniques like grid search, random search, or Bayesian optimization could find better parameters.
-
Advanced techniques: Deep learning, stacking, and other more advanced techniques could potentially boost performance, although they would be more complex to implement.
Conclusions
Predicting soccer match outcomes is a challenging but very valuable application of machine learning. Using the Soccer Fever dataset, we demonstrated two approaches using the Pycaret and Catboost libraries.
While both were able to build solid models, Catboost had the edge in performance, likely due to its superior handling of categorical features. Pycaret, however, was much simpler to use and still achieved good accuracy.
Ultimately, which library you choose may depend on your specific use case and how much you value simplicity vs. squeezing out every last bit of performance. Catboost is a great choice when performance is critical, while Pycaret is ideal for fast experimentation and iteration.
Examining feature importances revealed that team strength ratings and projected goals were the key drivers of the outcome predictions. Deriving additional novel features from the raw data could improve results further.
There are many additional techniques to explore for optimizing performance like ensembling and advanced hyperparameter tuning. Machine learning is a powerful tool for predicting soccer outcomes and delivering an edge to betting markets and club decision-makers.