forked from pnxenopoulos/awpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
162 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Win Probability Calculation\n", | ||
"\n", | ||
"We can use the win_probability function to calculate win probabilities at specific ticks in the match.\n", | ||
"\n", | ||
"First, you need to download the trained model file by running `awpy get winprob`. This will download a `.joblib` file to your current directory.\n", | ||
"\n", | ||
"Next, you need to import the win_probability function from the awpy library and parse the demo. This can be done by adding the following lines to the top of your code:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from awpy import Demo\n", | ||
"from awpy.stats.win_prob import win_probability\n", | ||
"dem = Demo('g2-vs-faze-m2-ancient.dem')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Let's choose some interesting ticks to analyze. For this example, we'll use ticks from different points in the match." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"ticks_to_analyze = [110716, 111110, 112935]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Now, let's calculate the win probabilities" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"probabilities = win_probability(dem, ticks_to_analyze)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The final step is to display the results" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"print(\"Win Probabilities:\")\n", | ||
"print(probabilities)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "raw", | ||
"metadata": {}, | ||
"source": [ | ||
"Win Probabilities:\n", | ||
" tick CT_win_probability T_win_probability\n", | ||
"0 110716 0.40 0.60\n", | ||
"1 111110 0.37 0.63\n", | ||
"2 112935 0.51 0.49" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "raw" | ||
} | ||
}, | ||
"source": [ | ||
"You can also analyze a single tick if you're interested in a specific moment" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from awpy import Demo\n", | ||
"from awpy.stats.win_prob import win_probability\n", | ||
"\n", | ||
"# Simply call `Demo(\"...\")` to parse a demo\n", | ||
"dem = Demo('g2-vs-faze-m2-ancient.dem')\n", | ||
"\n", | ||
"single_tick = 153063 \n", | ||
"single_tick_probability = win_probability(dem, single_tick)\n", | ||
"\n", | ||
"print(\"Win Probability for a single tick:\")\n", | ||
"print(single_tick_probability)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Training a Custom Model with Awpy\n", | ||
"\n", | ||
"This guide demonstrates how to use the `awpy train` CLI command to train your own model on a folder of Counter-Strike 2 demo files. This feature allows you to create custom win probability models based on your specific dataset.\n", | ||
"\n", | ||
"Before running the train model command, ensure you have a folder containing multiple .dem files. For this example, we'll assume you have a folder named `my_demos` with numerous demo files inside.\n", | ||
"\n", | ||
"### Basic Usage\n", | ||
"\n", | ||
"To train a model on your demo folder, use the following command:\n", | ||
"\n", | ||
"`awpy train my_demos/`\n", | ||
"\n", | ||
"This command will process all the demo files in the `my_demos` folder, extract relevant features, and train a win probability model. The trained model will be saved as `wpa_model_rf.joblib` in the current directory by default.\n", | ||
"\n", | ||
"### Advanced Usage\n", | ||
"\n", | ||
"The awpy train model command supports several options to customize the training process:\n", | ||
"\n", | ||
"`awpy train my_demos/ --output custom_model.joblib --batch-size 20`\n", | ||
"\n", | ||
"In this example:\n", | ||
"\n", | ||
"- `output custom_model.joblib` specifies a custom name and location for the output model file.\n", | ||
"- `batch-size 20` sets the number of demos to process in each batch, which can help manage memory usage for large datasets.\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |