Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,119 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
metrics:
|
6 |
+
- accuracy
|
7 |
+
base_model:
|
8 |
+
- gpt-omni/mini-omni
|
9 |
+
tags:
|
10 |
+
- not-for-all-audiences
|
11 |
+
- code
|
12 |
+
---
|
13 |
+
# ATP Tennis Match Analysis and Anomaly Detection
|
14 |
+
|
15 |
+
This project focuses on analyzing ATP tennis match data using a deep learning model with joint embedding techniques. The objective is to detect anomalies in professional men's tennis tournament draws using advanced statistical and machine learning methods. The project employs PyTorch for building and training the neural network, Optuna for hyperparameter optimization, and DBSCAN for anomaly detection.
|
16 |
+
|
17 |
+
## Table of Contents
|
18 |
+
|
19 |
+
- [Overview](#overview)
|
20 |
+
- [Features](#features)
|
21 |
+
- [Setup](#setup)
|
22 |
+
- [Usage](#usage)
|
23 |
+
- [Model Architecture](#model-architecture)
|
24 |
+
- [Hyperparameter Optimization](#hyperparameter-optimization)
|
25 |
+
- [Anomaly Detection](#anomaly-detection)
|
26 |
+
- [Results](#results)
|
27 |
+
- [Contributing](#contributing)
|
28 |
+
- [License](#license)
|
29 |
+
|
30 |
+
## Overview
|
31 |
+
|
32 |
+
The project aims to identify irregularities in tennis matches by examining patterns and discrepancies in player rankings, ages, and other match-related features. This analysis can help detect potential biases or unusual outcomes in tournament draws.
|
33 |
+
|
34 |
+
## Features
|
35 |
+
|
36 |
+
- **Data Loading and Preprocessing:** Handles ATP match data from multiple years, with preprocessing steps including encoding categorical features and handling missing values.
|
37 |
+
- **Feature Engineering:** Creates new features such as age difference and rank difference between players.
|
38 |
+
- **Joint Embedding Neural Network:** A PyTorch-based model that combines categorical and numerical features for robust prediction of match outcomes.
|
39 |
+
- **Hyperparameter Tuning:** Uses Optuna for efficient optimization of model hyperparameters.
|
40 |
+
- **Anomaly Detection:** Applies DBSCAN clustering to the embeddings generated by the model to identify anomalies in player performance.
|
41 |
+
|
42 |
+
## Setup
|
43 |
+
|
44 |
+
### Prerequisites
|
45 |
+
|
46 |
+
- Python 3.8 or later
|
47 |
+
- PyTorch
|
48 |
+
- Optuna
|
49 |
+
- Scikit-learn
|
50 |
+
- Matplotlib
|
51 |
+
- Pandas
|
52 |
+
- NumPy
|
53 |
+
|
54 |
+
### Installation
|
55 |
+
|
56 |
+
1. Clone the repository:
|
57 |
+
|
58 |
+
```bash
|
59 |
+
git clone https://github.com/yourusername/atp-tennis-analysis.git
|
60 |
+
cd atp-tennis-analysis
|
61 |
+
|
62 |
+
|
63 |
+
pip install -r requirements.txt
|
64 |
+
|
65 |
+
Download the ATP match data files and place them in the project directory.
|
66 |
+
Ensure the files are named in the format atp_matches_<year>.csv (e.g., atp_matches_2000.csv).
|
67 |
+
|
68 |
+
Run the main script to load data, preprocess it, and train the model:
|
69 |
+
python main.py
|
70 |
+
|
71 |
+
## Model Training
|
72 |
+
|
73 |
+
The script trains the model using the preprocessed data, optimizing hyperparameters with Optuna, and saves the best-performing model.
|
74 |
+
|
75 |
+
## Anomaly Detection
|
76 |
+
|
77 |
+
The model’s predictions are used to perform anomaly detection, identifying unusual matches or player performances.
|
78 |
+
|
79 |
+
## View Results
|
80 |
+
|
81 |
+
Results, including anomaly plots and metrics, will be saved in the output directory. CSV files summarizing the anomalies per player, year, and tournament will also be generated.
|
82 |
+
|
83 |
+
## Model Architecture
|
84 |
+
The JointEmbeddedModel consists of:
|
85 |
+
|
86 |
+
Embeddings for Categorical Features:
|
87 |
+
Each categorical variable (e.g., player IDs, tournament IDs) is embedded into a dense vector.
|
88 |
+
|
89 |
+
Fully Connected Layers:
|
90 |
+
These layers combine embeddings and numerical features to predict match outcomes.
|
91 |
+
|
92 |
+
Dropout Layers:
|
93 |
+
Used to prevent overfitting and improve model generalization.
|
94 |
+
|
95 |
+
## Hyperparameter Optimization
|
96 |
+
The project uses Optuna to automatically search for the best combination of model parameters, including:
|
97 |
+
|
98 |
+
Embedding dimension
|
99 |
+
|
100 |
+
Hidden layer size
|
101 |
+
|
102 |
+
Learning rate
|
103 |
+
|
104 |
+
Batch size
|
105 |
+
|
106 |
+
Dropout rate
|
107 |
+
|
108 |
+
## Anomaly Detection
|
109 |
+
Anomalies are detected by comparing expected and actual rank differences in matches using DBSCAN clustering. Anomalies can indicate unexpected match outcomes, potential biases, or errors in player rankings.
|
110 |
+
|
111 |
+
## Results
|
112 |
+
Positive Anomalies: Matches where the predicted rank difference was significantly lower than expected.
|
113 |
+
Negative Anomalies: Matches where the predicted rank difference was significantly higher than expected.
|
114 |
+
The results are visualized using TSNE plots and saved as images and CSV files.
|
115 |
+
|
116 |
+
## Contributions are welcome! Please feel free to submit a Pull Request or open an Issue for any improvements or bugs you encounter.
|
117 |
+
|
118 |
+
## License
|
119 |
+
This project is licensed under the MIT License. See the LICENSE file for more details.
|