All News

Experiencing Machine Learning with Premier League Data

26 minutes ago

I've been studying machine learning recently. To gain practical experience, I decided to work with Premier League data and apply machine learning techniques to it.

Using Premier League Match Data For this project, I used match result data from the 2024-2025 season. The data was downloaded fromthis site.

As the main features, I selected the following: Shots (HS, AS) Shots on Target (HST, AST) Fouls (HF, AF) Cards (HY, AY) The target variable is the match result (win, draw, or loss). Building a Machine Learning Model Here's the actual code I used: importpandasaspdfromsklearn.

Extract only necessary columnsfeatures=['HS','AS','HST','AST','HF','AF','HC','AC','HY','AY']# Shots, fouls, cards, etc. target='FTR'# Match result (H/D/A)# 3.

Create feature and target dataX=df[features]y=df[target]# 4. Label encoding (convert target variable to numbers)le=LabelEncoder()y_encoded=le.

fit_transform(y)# H->0, D->1, A->2, etc. Split into training and test dataX_train,X_test,y_train,y_test=train_test_split(X,y_encoded,test_size=0.2,random_state=42)# 6.

Create and train modelmodel=RandomForestClassifier(n_estimators=100,random_state=42)model. predict(X_test)print("Accuracy:",accuracy_score(y_test,y_pred))print("\nClassification Report:\n",classification_report(y_test,y_pred,target_names=le.

Save the trained model and label encoderjoblib. pkl') Enter fullscreen modeExit fullscreen mode Looking at Prediction Results and Evaluation When I ran the code, I got the following output: Accuracy: 0.5921052631578947 Classification Report: precision recall f1-score support A 0.62 0.75 0.68 28 D 0.15 0.12 0.14 16 H 0.76 0.69 0.72 32 accuracy 0.59 76 macro avg 0.51 0.52 0.51 76 weighted avg 0.58 0.59 0.58 76 Enter fullscreen modeExit fullscreen mode The accuracy (correct prediction rate) was 59%.

Looking at the details more closely, I can see that away wins (A) and home wins (H) have both high precision and recall, so the model predicts them fairly accurately. On the other hand, draws (D) are difficult for the model to predict.

Sebastian Hox

Written by

Sebastian Hox

Follow @SebastianHox
Share this story

Comments (0)