spells-mtg 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spells-mtg might be problematic. Click here for more details.
- spells_mtg-0.0.1/LICENSE +21 -0
- spells_mtg-0.0.1/PKG-INFO +465 -0
- spells_mtg-0.0.1/README.md +454 -0
- spells_mtg-0.0.1/pyproject.toml +39 -0
- spells_mtg-0.0.1/spells/__init__.py +5 -0
- spells_mtg-0.0.1/spells/cache.py +106 -0
- spells_mtg-0.0.1/spells/cards.py +96 -0
- spells_mtg-0.0.1/spells/columns.py +771 -0
- spells_mtg-0.0.1/spells/draft_data.py +300 -0
- spells_mtg-0.0.1/spells/enums.py +154 -0
- spells_mtg-0.0.1/spells/external.py +314 -0
- spells_mtg-0.0.1/spells/filter.py +137 -0
- spells_mtg-0.0.1/spells/manifest.py +184 -0
- spells_mtg-0.0.1/spells/schema.py +157 -0
- spells_mtg-0.0.1/tests/__init__.py +0 -0
- spells_mtg-0.0.1/tests/filter_test.py +126 -0
spells_mtg-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Joel Barnes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: spells-mtg
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: analaysis of 17Lands.com public datasets
|
|
5
|
+
Author-Email: Joel Barnes <oelarnes@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Requires-Dist: polars>=1.14.0
|
|
9
|
+
Requires-Dist: wget>=3.2
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# 🪄 spells ✨
|
|
13
|
+
|
|
14
|
+
**spells** is a python package that tutors up blazing-fast and extensible analysis of the public data sets provided by [17Lands](https://www.17lands.com/) and exiles the annoying and slow parts of your workflow. Spells exposes one first-class function, `summon`, which summons a Polars DataFrame to the battlefield.
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
$ spells add DSK
|
|
18
|
+
🪄 spells ✨ [data home]=/Users/joel/.local/share/spells/
|
|
19
|
+
|
|
20
|
+
🪄 add ✨ Downloading draft dataset from 17Lands.com
|
|
21
|
+
100% [......................................................................] 250466473 / 250466473
|
|
22
|
+
🪄 add ✨ Unzipping and transforming to parquet...
|
|
23
|
+
🪄 add ✨ File /Users/joel/.local/share/spells/external/DSK/DSK_PremierDraft_draft.parquet written
|
|
24
|
+
🪄 clean ✨ No local cache found for set DSK
|
|
25
|
+
🪄 add ✨ Downloading game dataset from 17Lands.com
|
|
26
|
+
100% [........................................................................] 77145600 / 77145600
|
|
27
|
+
🪄 add ✨ Unzipping and transforming to parquet...
|
|
28
|
+
🪄 add ✨ File /Users/joel/.local/share/spells/external/DSK/DSK_PremierDraft_game.parquet written
|
|
29
|
+
🪄 clean ✨ No local cache found for set DSK
|
|
30
|
+
🪄 add ✨ Fetching card data from mtgjson.com and writing card parquet file
|
|
31
|
+
🪄 add ✨ Wrote 287 lines to file /Users/joel/.local/share/spells/external/DSK/DSK_card.parquet
|
|
32
|
+
$ ipython
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
In [1]: from spells import summon
|
|
37
|
+
|
|
38
|
+
In [2]: %time summon('DSK')
|
|
39
|
+
CPU times: user 20.3 s, sys: 7.9 s, total: 28.2 s
|
|
40
|
+
Wall time: 7.55 s
|
|
41
|
+
Out[2]:
|
|
42
|
+
shape: (286, 14)
|
|
43
|
+
┌────────────────────────────┬───────┬──────────┬──────────┬───┬────────┬──────────┬─────────┬──────────┐
|
|
44
|
+
│ name ┆ color ┆ rarity ┆ num_seen ┆ … ┆ num_oh ┆ oh_wr ┆ num_gih ┆ gih_wr │
|
|
45
|
+
│ --- ┆ --- ┆ --- ┆ --- ┆ ┆ --- ┆ --- ┆ --- ┆ --- │
|
|
46
|
+
│ str ┆ str ┆ str ┆ i64 ┆ ┆ i64 ┆ f64 ┆ i64 ┆ f64 │
|
|
47
|
+
╞════════════════════════════╪═══════╪══════════╪══════════╪═══╪════════╪══════════╪═════════╪══════════╡
|
|
48
|
+
│ Abandoned Campground ┆ ┆ common ┆ 178750 ┆ … ┆ 21350 ┆ 0.559672 ┆ 49376 ┆ 0.547594 │
|
|
49
|
+
│ Abhorrent Oculus ┆ U ┆ mythic ┆ 6676 ┆ … ┆ 4255 ┆ 0.564042 ┆ 11287 ┆ 0.593337 │
|
|
50
|
+
│ Acrobatic Cheerleader ┆ W ┆ common ┆ 308475 ┆ … ┆ 34177 ┆ 0.541709 ┆ 74443 ┆ 0.532152 │
|
|
51
|
+
│ Altanak, the Thrice-Called ┆ G ┆ uncommon ┆ 76981 ┆ … ┆ 13393 ┆ 0.513925 ┆ 34525 ┆ 0.539175 │
|
|
52
|
+
│ Anthropede ┆ G ┆ common ┆ 365380 ┆ … ┆ 8075 ┆ 0.479876 ┆ 20189 ┆ 0.502353 │
|
|
53
|
+
│ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … ┆ … │
|
|
54
|
+
│ Wildfire Wickerfolk ┆ GR ┆ uncommon ┆ 98040 ┆ … ┆ 18654 ┆ 0.592366 ┆ 42251 ┆ 0.588696 │
|
|
55
|
+
│ Winter's Intervention ┆ B ┆ common ┆ 318565 ┆ … ┆ 27552 ┆ 0.537638 ┆ 66921 ┆ 0.548453 │
|
|
56
|
+
│ Winter, Misanthropic Guide ┆ BGR ┆ rare ┆ 52091 ┆ … ┆ 1261 ┆ 0.462331 ┆ 3183 ┆ 0.479422 │
|
|
57
|
+
│ Withering Torment ┆ B ┆ uncommon ┆ 76237 ┆ … ┆ 15901 ┆ 0.511729 ┆ 39323 ┆ 0.542024 │
|
|
58
|
+
│ Zimone, All-Questioning ┆ GU ┆ rare ┆ 20450 ┆ … ┆ 9510 ┆ 0.654574 ┆ 23576 ┆ 0.616686 │
|
|
59
|
+
└────────────────────────────┴───────┴──────────┴──────────┴───┴────────┴──────────┴─────────┴──────────┘
|
|
60
|
+
|
|
61
|
+
In [3]: %time spells.summon('DSK')
|
|
62
|
+
CPU times: user 16.3 ms, sys: 66.2 ms, total: 82.5 ms
|
|
63
|
+
Wall time: 80.8 ms
|
|
64
|
+
```
|
|
65
|
+
Coverting to pandas DataFrame is as simple as invoking the chained call `summon(...).to_pandas()`.
|
|
66
|
+
|
|
67
|
+
Spells is not affiliated with 17Lands. Please review the Usage Guidelines for 17lands data before using Spells, and consider supporting their patreon. Spells is free and open-source; please consider contributing and feel free to make use of the source code under the terms of the MIT license.
|
|
68
|
+
|
|
69
|
+
## spells
|
|
70
|
+
|
|
71
|
+
- Uses [Polars](https://docs.pola.rs/) for high-performance, multi-threaded aggregations of large datasets
|
|
72
|
+
- Uses Polars to power an expressive query language for specifying custom extensions and optimizing complex queries
|
|
73
|
+
- Converts csv datasets to parquet for 10x faster calculations and 20x smaller file sizes
|
|
74
|
+
- Supports calculating the standard aggregations and measures out of the box with no arguments (ALSA, GIH WR, etc)
|
|
75
|
+
- Caches aggregate DataFrames in the local file system automatically for instantaneous reproduction of previous analysis
|
|
76
|
+
- Manages grouping and filtering by built-in and custom columns at the row level
|
|
77
|
+
- Provides 116 explicitly specified, enumerated, documented column definitions
|
|
78
|
+
- Supports "Deck Color Data" aggregations with built-in column definitions.
|
|
79
|
+
- Provides a CLI tool `spells [add|refresh|clean|remove|info] [SET]` to download and manage external files
|
|
80
|
+
- Downloads and manages public datasets from 17Lands
|
|
81
|
+
- Downloads and models booster configuration and card data from [MTGJSON](https://mtgjson.com/)
|
|
82
|
+
- Is fully typed, linted, and statically analyzed for support of advanced IDE features
|
|
83
|
+
- Provides optional enums for all base columns and built-in extensions, as well as for custom extension parameters
|
|
84
|
+
- Uses Polars expressions to support second-stage aggregations and beyond like game-weighted z-scores with one call to summon
|
|
85
|
+
|
|
86
|
+
## summon
|
|
87
|
+
|
|
88
|
+
`summon` takes four optional arguments, allowing a fully declarative specification of your desired analysis. Basic functionality not provided by this api can often be managed by simple chained calls using the polars API, e.g. sorting and post-agg filtering.
|
|
89
|
+
- `columns` specifies the desired output columns
|
|
90
|
+
```python
|
|
91
|
+
>>> spells.summon('DSK', columns=["num_gp", "pct_gp", "gp_wr", "gp_wr_z"])
|
|
92
|
+
shape: (286, 5)
|
|
93
|
+
┌────────────────────────────┬────────┬──────────┬──────────┬───────────┐
|
|
94
|
+
│ name ┆ num_gp ┆ pct_gp ┆ gp_wr ┆ gp_wr_z │
|
|
95
|
+
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
|
|
96
|
+
│ str ┆ i64 ┆ f64 ┆ f64 ┆ f64 │
|
|
97
|
+
╞════════════════════════════╪════════╪══════════╪══════════╪═══════════╡
|
|
98
|
+
│ Abandoned Campground ┆ 114632 ┆ 0.643404 ┆ 0.546444 ┆ 0.12494 │
|
|
99
|
+
│ Abhorrent Oculus ┆ 26046 ┆ 0.908476 ┆ 0.561852 ┆ 1.245212 │
|
|
100
|
+
│ Acrobatic Cheerleader ┆ 188674 ┆ 0.705265 ┆ 0.541474 ┆ -0.236464 │
|
|
101
|
+
│ Altanak, the Thrice-Called ┆ 87285 ┆ 0.798662 ┆ 0.538695 ┆ -0.438489 │
|
|
102
|
+
│ Anthropede ┆ 50634 ┆ 0.214676 ┆ 0.515444 ┆ -2.129016 │
|
|
103
|
+
│ … ┆ … ┆ … ┆ … ┆ … │
|
|
104
|
+
│ Wildfire Wickerfolk ┆ 106557 ┆ 0.725806 ┆ 0.565331 ┆ 1.498173 │
|
|
105
|
+
│ Winter's Intervention ┆ 157534 ┆ 0.616868 ┆ 0.531758 ┆ -0.942854 │
|
|
106
|
+
│ Winter, Misanthropic Guide ┆ 7794 ┆ 0.197207 ┆ 0.479985 ┆ -4.70721 │
|
|
107
|
+
│ Withering Torment ┆ 92468 ┆ 0.875387 ┆ 0.525858 ┆ -1.371877 │
|
|
108
|
+
│ Zimone, All-Questioning ┆ 54687 ┆ 0.844378 ┆ 0.560974 ┆ 1.181387 │
|
|
109
|
+
└────────────────────────────┴────────┴──────────┴──────────┴───────────┘
|
|
110
|
+
```
|
|
111
|
+
- `group_by` specifies the grouping by one or more columns. By default, group by card names, but optionally group by any of a large set of fundamental and derived columns, including card attributes and your own custom extension.
|
|
112
|
+
```python
|
|
113
|
+
>>> spells.summon('BLB', columns=["num_won", "num_games", "game_wr"], group_by=["main_colors"], filter_spec={"num_colors": 2})
|
|
114
|
+
shape: (10, 4)
|
|
115
|
+
┌─────────────┬─────────┬───────────┬──────────┐
|
|
116
|
+
│ main_colors ┆ num_won ┆ num_games ┆ game_wr │
|
|
117
|
+
│ --- ┆ --- ┆ --- ┆ --- │
|
|
118
|
+
│ str ┆ u32 ┆ u32 ┆ f64 │
|
|
119
|
+
╞═════════════╪═════════╪═══════════╪══════════╡
|
|
120
|
+
│ BG ┆ 85022 ┆ 152863 ┆ 0.556197 │
|
|
121
|
+
│ BR ┆ 45900 ┆ 81966 ┆ 0.559988 │
|
|
122
|
+
│ RG ┆ 34641 ┆ 64428 ┆ 0.53767 │
|
|
123
|
+
│ UB ┆ 30922 ┆ 57698 ┆ 0.535928 │
|
|
124
|
+
│ UG ┆ 59879 ┆ 109145 ┆ 0.548619 │
|
|
125
|
+
│ UR ┆ 19638 ┆ 38679 ┆ 0.507717 │
|
|
126
|
+
│ WB ┆ 59480 ┆ 107443 ┆ 0.553596 │
|
|
127
|
+
│ WG ┆ 76134 ┆ 136832 ┆ 0.556405 │
|
|
128
|
+
│ WR ┆ 49712 ┆ 91224 ┆ 0.544944 │
|
|
129
|
+
│ WU ┆ 16483 ┆ 31450 ┆ 0.524102 │
|
|
130
|
+
└─────────────┴─────────┴───────────┴──────────┘
|
|
131
|
+
```
|
|
132
|
+
- `filter_spec` specifies a row-level filter for the dataset, using an intuitive custom query formulation
|
|
133
|
+
```python
|
|
134
|
+
>>> from spells.enums import ColName
|
|
135
|
+
>>> spells.summon('BLB', columns=["game_wr"], group_by=["player_cohort"], filter_spec={'lhs': 'num_mulligans', 'op': '>', 'rhs': 0})
|
|
136
|
+
shape: (4, 2)
|
|
137
|
+
┌───────────────┬──────────┐
|
|
138
|
+
│ player_cohort ┆ game_wr │
|
|
139
|
+
│ --- ┆ --- │
|
|
140
|
+
│ str ┆ f64 │
|
|
141
|
+
╞═══════════════╪══════════╡
|
|
142
|
+
│ Bottom ┆ 0.33233 │
|
|
143
|
+
│ Middle ┆ 0.405346 │
|
|
144
|
+
│ Other ┆ 0.406151 │
|
|
145
|
+
│ Top ┆ 0.475763 │
|
|
146
|
+
└───────────────┴──────────┘
|
|
147
|
+
```
|
|
148
|
+
- `extensions` allows for the specification of arbitrarily complex derived columns and aggregations, including custom columns built on top of custom columns.
|
|
149
|
+
```python
|
|
150
|
+
>>> import polars as pl
|
|
151
|
+
>>> from spells.columns import ColumnSpec
|
|
152
|
+
>>> from spells.enums import ColType, View, ColName
|
|
153
|
+
>>> ext = ColumnSpec(
|
|
154
|
+
... name='deq_base',
|
|
155
|
+
... col_type=ColType.AGG,
|
|
156
|
+
... expr=(pl.col('gp_wr_excess') + 0.03 * (1 - pl.col('ata')/14).pow(2)) * pl.col('pct_gp'),
|
|
157
|
+
... dependencies=['gp_wr_excess', 'ata', 'pct_gp']
|
|
158
|
+
...)
|
|
159
|
+
>>> spells.summon('DSK', columns=['deq_base', 'color', 'rarity'], filter_spec={'player_cohort': 'Top'}, extensions=[ext])
|
|
160
|
+
... .filter(pl.col('deq_base').is_finite())
|
|
161
|
+
... .filter(pl.col('rarity').is_in(['common', 'uncommon'])
|
|
162
|
+
... .sort('deq_base', descending=True)
|
|
163
|
+
... .head(10)
|
|
164
|
+
shape: (10, 4)
|
|
165
|
+
┌──────────────────────────┬──────────┬──────────┬───────┐
|
|
166
|
+
│ name ┆ deq_base ┆ rarity ┆ color │
|
|
167
|
+
│ --- ┆ --- ┆ --- ┆ --- │
|
|
168
|
+
│ str ┆ f64 ┆ str ┆ str │
|
|
169
|
+
╞══════════════════════════╪══════════╪══════════╪═══════╡
|
|
170
|
+
│ Sheltered by Ghosts ┆ 0.03945 ┆ uncommon ┆ W │
|
|
171
|
+
│ Optimistic Scavenger ┆ 0.036131 ┆ uncommon ┆ W │
|
|
172
|
+
│ Midnight Mayhem ┆ 0.034278 ┆ uncommon ┆ RW │
|
|
173
|
+
│ Splitskin Doll ┆ 0.03423 ┆ uncommon ┆ W │
|
|
174
|
+
│ Fear of Isolation ┆ 0.033901 ┆ uncommon ┆ U │
|
|
175
|
+
│ Floodpits Drowner ┆ 0.033198 ┆ uncommon ┆ U │
|
|
176
|
+
│ Gremlin Tamer ┆ 0.032048 ┆ uncommon ┆ UW │
|
|
177
|
+
│ Arabella, Abandoned Doll ┆ 0.032008 ┆ uncommon ┆ RW │
|
|
178
|
+
│ Unnerving Grasp ┆ 0.030278 ┆ uncommon ┆ U │
|
|
179
|
+
│ Oblivious Bookworm ┆ 0.028605 ┆ uncommon ┆ GU │
|
|
180
|
+
└──────────────────────────┴──────────┴──────────┴───────┘
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Note the use of chained calls to the Polars DataFrame api to perform manipulations on the result of `summon`.
|
|
184
|
+
|
|
185
|
+
## Installation
|
|
186
|
+
|
|
187
|
+
Spells is available on PyPI as *spells-mtg*, and can be installed using pip or any package manager:
|
|
188
|
+
|
|
189
|
+
`pip install spells-mtg`
|
|
190
|
+
|
|
191
|
+
Spells is still in development and could benefit from many new features and improvements. As such, you might rather clone this repository and install locally. It is set up to use pdm, but it's just a regular old python package and you can install with your normal workflow.
|
|
192
|
+
|
|
193
|
+
If you are new to Python, I recommend using a package manager like poetry, pdm or uv to create a virtual environment and manage your project.
|
|
194
|
+
|
|
195
|
+
## Why did you make this? Who is it for?
|
|
196
|
+
|
|
197
|
+
Earlier this year I developed a card quality metric called [DEq](https://docs.google.com/spreadsheets/d/1n1pfrb5q_2ICYk-vfF3Uwo8t61DJU-5T_DFe0dwk8DY/edit), short for "Estimated Draft Equity", which is designed to estimate the average value of selecting a card in draft relative to a comparable baseline, in order to improve on commonly-used metrics like GIH WR, which has a number of major and minor problems when interpreted as a card quality metric. DEq depends on the daily drops from 17Lands.com and won't be replaced by this static kind of analysis.
|
|
198
|
+
|
|
199
|
+
While the modeling underpinning DEq remains sound, the estimation of the value depends on several parameters which should be inferred statistically, particularly the value of a pick and the pool bias estimate, and that process has been, let's say, somewhat less sound. In order to provide more scientific estimates of the parameters, and to continue on with deeper research, I felt the need to build a python library to enable quicker iteration and concise, portable declarations of analysis.
|
|
200
|
+
|
|
201
|
+
That need compounded with a feeling that the barrier to entry to working with these datasets is too high and that a tool like this would benefit the community. So that's what this is. It is for data-curious beginning programmers and professional developers and scientists. I hope you find it useful.
|
|
202
|
+
|
|
203
|
+
If you're interested in the fruits of my DEq research, or in checking my work, keep an eye on my [deq](https://GitHub.com/oelarnes/deq) repository.
|
|
204
|
+
|
|
205
|
+
## Performance
|
|
206
|
+
|
|
207
|
+
Spells provides several features out of the box to optimize performance to the degree possible given its generality.
|
|
208
|
+
|
|
209
|
+
### Parquet Transformation
|
|
210
|
+
|
|
211
|
+
The most significant optimization used by Spells is the simplest: the csv files are scanned and streamed to Parquet files by Polars. This allows 10x faster compute times with 20x less storage space and lower memory usage compared to csv. Yes, the files are twenty times smaller and ten times faster!
|
|
212
|
+
|
|
213
|
+
### Query Optimization
|
|
214
|
+
|
|
215
|
+
Firstly, it is built on top of Polars, a modern, well-supported DataFrame engine written for performance in Rust that enables declarative query plans and lazy evaluation, allowing for automatic performance optimization in the execution of the query plan. Spells selects only the necessary columns for your analysis using an optimized recursive selection algorithm traversing the dependency tree.
|
|
216
|
+
|
|
217
|
+
### Local Caching
|
|
218
|
+
|
|
219
|
+
Additionally, by default, Spells caches the results of expensive aggregations in the local file system as parquet files, which by default are found under the `data/local` path from the execution directory, which can be configured using the environment variable `SPELLS_PROJECT_DIR`. Query plans which request the same set of first-stage aggregations (sums over base rows) will attempt to locate the aggregate data in the cache before calculating. This guarantees that a repeated call to `summon` returns instantaneously.
|
|
220
|
+
|
|
221
|
+
When refreshing a given set's data files from 17Lands using the provided cli, the cache for that set is automatically cleared. The `spells` CLI gives additional tools for managing the local and external caches.
|
|
222
|
+
|
|
223
|
+
# Documentation
|
|
224
|
+
In order to give a valid specification for more complex queries, it's important to understand a bit about what Spells is doing under the hood.
|
|
225
|
+
|
|
226
|
+
## Basic Concepts
|
|
227
|
+
Let's briefly review the structure of the underlying data. Spells supports aggregations on two of the three large data sets provided by 17Lands, which
|
|
228
|
+
are identified as "views" within Spells. First there is *draft*, which is the source for information about draft picks. The row model is single draft picks with pack and pool context. Unlike *game*, there are two different paradigms for aggregating over card names.
|
|
229
|
+
|
|
230
|
+
First, one can group by the value of the "pick" column and sum numerical column values. This is how ATA is calculated. In Spells, we tag columns to be summed in this way as *pick_sum* columns. For example, "taken_at" is equivalent to "pick_number", but whereas the latter is available for grouping, "taken_at" is summed over groups.
|
|
231
|
+
|
|
232
|
+
Second, certain columns are pivoted horizontally within the raw data and suffixed with card names, for example "pack_card_Savor". In Spells we tag such columns as *name_sum*, and group by non-name columns and sum before unpivoting. The columns are identified by their prefix only and Spells handles the mapping.
|
|
233
|
+
|
|
234
|
+
A standard way to aggregate information in non-*name_sum* columns over names is to multiply that column over the pivoted column. For example, to calculate the *name_sum* column "last_seen", used in ALSA, we multiply "pack_card" by a modified version of "pick_number".
|
|
235
|
+
|
|
236
|
+
In the *game* file, the row model represents games, and primarily uses *name_sum* aggregations for the familiar columns, such as "num_gih", from which win rates are derived. For groupings that do not use card names or card attributes (to recreate the "deck color data" page, for example), one can also specify *game_sum* columns which aggregate simply over rows.
|
|
237
|
+
|
|
238
|
+
### Aggregate View
|
|
239
|
+
|
|
240
|
+
Once aggregation columns, filters and groupings are determined at the row level for each of the required base views, Spells asks Polars to sum over groups and unpivot as needed to produce the "base aggregate view", which fixes the row model (pre-card attributes) to the provided base groupings. This base aggregate view is cached by default to the local file system, keyed by the *manifest*, which is a function of the specification provided by the user.
|
|
241
|
+
|
|
242
|
+
Next, card attributes are calculated and joined to the base aggregate view by name, and an additional grouping is performed if requested by the user to produce the *aggregate view*.
|
|
243
|
+
|
|
244
|
+
A final extension and selection stage is applied to the aggregate view, which is where weighted averages like GIH WR are calculated. Polars expression language enables aggregations to be represented as expressions and broadcast back to the row level, enabling Spells to support arbitrary chains of aggregation and extension at the aggregate view level. For example, one could calculate the mean of a metric over groups by archetype, regress a metric by a function of that mean, then calculate the mean of that regressed metric, all expressed declaratively as column expressions and simply specified by name in the `summon` api call.
|
|
245
|
+
|
|
246
|
+
So that's it, that's what Spells does from a high level. `summon` will hand off a Polars DataFrame which can be cast to pandas, sorted, filtered, used to be generate plots or whatever you like. If a task can be handled as easily via a chained call or outside library, it should stay that way, but if you have a request for features specific to the structure of limited data that could be handled in a general way, please reach out! In particular I am interested in scientific workflows like maximum likelihood estimation, but I haven't yet considered how to build it into Spells.
|
|
247
|
+
|
|
248
|
+
## CLI
|
|
249
|
+
|
|
250
|
+
Spells includes a command-line interface `spells` to manage your external data files and local cache. Spells will download files to an appropriate file location on your system,
|
|
251
|
+
typically `~/.local/share/spells` on Unix-like platforms and `C:\Users\{Username}\AppData\Local\Spells` on Windows.
|
|
252
|
+
To use `spells`, make sure Spells in installed in your environment using pip or a package manager, and type `spells help` into your shell, or dive in with `spells add DSK` or your favorite set.
|
|
253
|
+
|
|
254
|
+
## API
|
|
255
|
+
|
|
256
|
+
### Summon
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
from spell import summon
|
|
260
|
+
|
|
261
|
+
summon(
|
|
262
|
+
columns: list[str] | None = None,
|
|
263
|
+
group_by: list[str] | None = None,
|
|
264
|
+
filter_spec: dict | None = None,
|
|
265
|
+
extensions: list[str] | None = None,
|
|
266
|
+
) -> polars.DataFrame
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
#### parameters
|
|
270
|
+
|
|
271
|
+
- columns: a list of string or `ColName` values to select as non-grouped columns. Valid `ColTypes` are `PICK_SUM`, `NAME_SUM`, `GAME_SUM`, `CARD_ATTR`, `AGG`. Min/Max/Unique
|
|
272
|
+
aggregations of non-numeric (or numeric) data types are not supported. If `None`, use a set of columns modeled on the commonly used values on 17Lands.com/card_data.
|
|
273
|
+
|
|
274
|
+
- group_by: a list of string or `ColName` values to display as grouped columns. Valid `ColTypes` are `GROUP_BY` and `CARD_ATTR`. By default, group by "name" (card name).
|
|
275
|
+
|
|
276
|
+
- filter_spec: a dictionary specifying a filter, using a small number of paradigms. Columns used must be in each base view ("draft" and "game") that the `columns` and `group_by` columns depend on, so
|
|
277
|
+
`AGG` and `CARD_ATTR` columns are not valid. `NAME_SUM` columns are also not supported. Derived columns are supported. No filter is applied by default. Yes, I should rewrite it to use the mongo query language. The specification is best understood with examples:
|
|
278
|
+
|
|
279
|
+
- `{'player_cohort': 'Top'}` "player_cohort" value equals "Top".
|
|
280
|
+
- `{'lhs': 'player_cohort', 'op': 'in', 'rhs': ['Top', 'Middle']}` "player_cohort" value is either "Top" or "Middle". Supported values for `op` are `<`, `<=`, `>`, `>=`, `!=`, `=`, `in` and `nin`.
|
|
281
|
+
- `{'$and': [{'lhs': 'draft_date', 'op': '>', 'rhs': datetime.date(2024, 10, 7)}, {'rank': 'Mythic'}]}` Drafts after October 7 by Mythic-ranked players. Supported values for query construction keys are `$and`, `$or`, and `$not`.
|
|
282
|
+
|
|
283
|
+
- extensions: a list of `spells.columns.ColumnSpec` objects, which are appended to the definitions built-in columns described below. A name not in the enum `ColName` can be used in this way if it is the name of a provided extension. Existing names can also be redefined using extensions.
|
|
284
|
+
|
|
285
|
+
### Enums
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
from spells.enums import ColName, ColType, View
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Recommended to import `ColName` for any usage of `summon`, and to import `ColType` and `View` when defining custom extensions.
|
|
292
|
+
|
|
293
|
+
### ColumnSpec
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
from spells.columns import ColumnSpec
|
|
297
|
+
|
|
298
|
+
ColumnSpec(
|
|
299
|
+
name: str,
|
|
300
|
+
col_type: spells.enums.ColType,
|
|
301
|
+
views: tuple(spells.enums.View...) = (),
|
|
302
|
+
expr: pl.Expr | None = None,
|
|
303
|
+
exprMap: Callable[[str], pl.Expr] | None = None
|
|
304
|
+
dependencies: list[str] | None = None
|
|
305
|
+
version: str | None = None
|
|
306
|
+
)
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Used to define extensions in `summon`
|
|
310
|
+
|
|
311
|
+
#### parameters
|
|
312
|
+
|
|
313
|
+
- `name`: any string, including existing columns, although this is very likely to break dependent columns, so don't do it. For `NAME_SUM` columns, the name is the prefix without the underscore, e.g. "drawn".
|
|
314
|
+
|
|
315
|
+
- `col_type`: one of the `ColType` enum values, `FILTER_ONLY`, `GROUP_BY`, `PICK_SUM`, `NAME_SUM`, `GAME_SUM`, `CARD_ATTR`, and `AGG`. See documentation for `summon` for usage. All columns except `CARD_ATTR` and `AGG` must be derivable at the individual row level on one or both base views. `CARD_ATTR` must be derivable at the individual row level from the card file. `AGG` can depend on any column present after summing over groups, and can include polars Expression aggregations. Arbitrarily long chains of aggregate dependencies are supported.
|
|
316
|
+
|
|
317
|
+
- `views`: For a column defined at the row level on a view (see col_types above), the views on which it is supported. All col_types except `AGG` must specify at least one base view. For `CARD_ATTR` columns, `views` must be exactly `(View.CARD,)`.
|
|
318
|
+
|
|
319
|
+
- `expr`: A polars expression giving the derivation of the column value at the first level where it is defined. For `NAME_SUM` columns the `exprMap` attribute must be used instead. `AGG` columns that depend on `NAME_SUM` columns reference the prefix (`cdef.name`) only, since the unpivot has occured prior to selection.
|
|
320
|
+
|
|
321
|
+
- `exprMap`: A function of card name that returns the expression for a `NAME_SUM` column.
|
|
322
|
+
|
|
323
|
+
- `dependencies`: A list of column names. All dependencies must be declared by name.
|
|
324
|
+
|
|
325
|
+
- `version`: When defining a column using a python function, as opposed to Polars expressions, add a unique version number so that the unique hashed signature of the column specification can be derived
|
|
326
|
+
for caching purposes, since Polars cannot generate a serialization natively. When changing the definition, be sure to increment the version value. Otherwise you do not need to use this parameter.
|
|
327
|
+
|
|
328
|
+
### Columns
|
|
329
|
+
|
|
330
|
+
A table of all included columns. Columns can be referenced by enum or by string value in arguments and filter specs. The string value is always the lowercase version of the enum attribute.
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
| `ColName` | **Name** | `View` | `ColType` | **Description** | **Type** |
|
|
334
|
+
| --------------------------- | ---------------------------- | ------------- | ------------- | --------------- | --------------- |
|
|
335
|
+
| `NAME` | `"name"` | | `GROUP_BY` | Special handling, don't use in `filter_spec` | String |
|
|
336
|
+
| `EXPANSION` | `"expansion"` | `DRAFT, GAME` | `GROUP_BY` | Dataset Column | String |
|
|
337
|
+
| `EVENT_TYPE` | `"event_type"` | `DRAFT, GAME` | `GROUP_BY` | Dataset Column | String |
|
|
338
|
+
| `DRAFT_ID` | `"draft_id"` | `DRAFT, GAME` | `FILTER_ONLY` | Dataset column | String |
|
|
339
|
+
| `DRAFT_TIME` | `"draft_time"` | `DRAFT, GAME` | `FILTER_ONLY` | Dataset column | String |
|
|
340
|
+
| `DRAFT_DATE` | `"draft_date"` | `DRAFT, GAME` | `GROUP_BY` | | `datetime.date` |
|
|
341
|
+
| `DRAFT_DAY_OF_WEEK` | `"draft_day_of_week` | `DRAFT, GAME` | `GROUP_BY` | 1-7 (Mon-Sun) | Int |
|
|
342
|
+
| `DRAFT_HOUR` | `"draft_hour"` | `DRAFT, GAME` | `GROUP_BY` | 0-23 | Int |
|
|
343
|
+
| `DRAFT_WEEK` | `"draft_week"` | `DRAFT, GAME` | `GROUP_BY` | 1-53 | Int |
|
|
344
|
+
| `RANK` | `"rank"` | `DRAFT, GAME` | `GROUP_BY` | Dataset column | String |
|
|
345
|
+
| `USER_N_GAMES_BUCKET` | `"user_n_games_bucket"` | `DRAFT, GAME` | `GROUP_BY` | Dataset Column | Int |
|
|
346
|
+
| `USER_GAME_WIN_RATE_BUCKET` | `"user_game_win_rate_bucket` | `DRAFT, GAME` | `GROUP_BY` | Dataset Column | Float |
|
|
347
|
+
| `PLAYER_COHORT` | `"player_cohort"` | `DRAFT, GAME` | `GROUP_BY` | In-sample version of "Top", "Middle", "Bottom", etc based on `USER_GAME_WIN_RATE_BUCKET`. Thresholds are 49% and 57% and 100 games played. | String |
|
|
348
|
+
| `EVENT_MATCH_WINS` | `"event_match_wins` | `DRAFT` | `GROUP_BY` | Dataset Column | Int |
|
|
349
|
+
| `EVENT_MATCH_WINS_SUM` | `"event_match_wins_sum` | `DRAFT` | `PICK_SUM` | | Int |
|
|
350
|
+
| `EVENT_MATCH_LOSSES` | `"event_match_losses` | `DRAFT` | `GROUP_BY` | Dataset Column | Int |
|
|
351
|
+
| `EVENT_MATCH_LOSSES_SUM` | `"event_match_losses_sum"` | `DRAFT` | `PICK_SUM` | | Int |
|
|
352
|
+
| `EVENT_MATCHES` | `"event_matches"` | `DRAFT` | `GROUP_BY` | | Int |
|
|
353
|
+
| `EVENT_MATCHES_SUM` | `"event_matches_sum"` | `DRAFT` | `PICK_SUM` | | Int |
|
|
354
|
+
| `IS_TROPHY` | `"is_trophy"` | `DRAFT` | `GROUP_BY` | 3 Match Wins if "Traditional", 7 if Premier | Boolean |
|
|
355
|
+
| `IS_TROPHY_SUM` | `"is_trophy_sum"` | `DRAFT` | `PICK_SUM` | | Int |
|
|
356
|
+
| `PACK_NUMBER` | `"pack_number` | `DRAFT` | `FILTER_ONLY` | Dataset Column | Int |
|
|
357
|
+
| `PACK_NUM` | `"pack_num"` | `DRAFT` | `GROUP_BY` | 1-indexed | Int |
|
|
358
|
+
| `PICK_NUMBER` | `"pick_number"` | `DRAFT` | `FILTER_ONLY` | Dataset Column | Int |
|
|
359
|
+
| `PICK_NUM` | `"pick_num"` | `DRAFT` | `GROUP_BY` | 1-indexed | Int |
|
|
360
|
+
| `TAKEN_AT` | `"taken_at` | `DRAFT` | `PICK_SUM` | Summable alias of `PICK_NUM` | Int |
|
|
361
|
+
| `NUM_TAKEN` | `"num_taken"` | `DRAFT` | `PICK_SUM` | Sum 1 over rows | Int |
|
|
362
|
+
| `PICK` | `"pick"` | `DRAFT` | `FILTER_ONLY` | Dataset Column, joined as "name" | String |
|
|
363
|
+
| `PICK_MAINDECK_RATE` | `"pick_maindeck_rate"` | `DRAFT` | `PICK_SUM` | Dataset Column | Float |
|
|
364
|
+
| `PICK_SIDEBOARD_IN_RATE` | `"pick_sideboard_in_rate` | `DRAFT` | `PICK_SUM` | Dataset Column | Float |
|
|
365
|
+
| `PACK_CARD` | `"pack_card` | `DRAFT` | `NAME_SUM` | Dataset Column | Int |
|
|
366
|
+
| `LAST_SEEN` | `"last_seen"` | `DRAFT` | `NAME_SUM` | `PACK_CARD` times `min(8, PICK_NUM)`, add 8 to give last pick num seen when summed | Int |
|
|
367
|
+
| `NUM_SEEN` | `"num_seen"` | `DRAFT` | `NAME_SUM` | `PACK_CARD` for `PICK_NUM` less than 9 | Int |
|
|
368
|
+
| `POOL` | `"pool"` | `DRAFT` | `NAME_SUM` | Dataset Column | Int |
|
|
369
|
+
| `GAME_TIME` | `"game_time"` | `GAME` | `FILTER_ONLY` | Dataset Column | String |
|
|
370
|
+
| `GAME_DATE` | `"game_date"` | `GAME` | `GROUP_BY` | | `datetime.date` |
|
|
371
|
+
| `GAME_DAY_OF_WEEK` | `"game_day_of_week` | `GAME` | `GROUP_BY` | 1-7 (Mon-Sun) | Int |
|
|
372
|
+
| `GAME_HOUR` | `"game_hour"` | `GAME` | `GROUP_BY` | 0-23 | Int |
|
|
373
|
+
| `GAME_WEEK` | `"game_week"` | `GAME` | `GROUP_BY` | 1-53 | Int |
|
|
374
|
+
| `BUILD_INDEX` | `"build_index"` | `GAME` | `GROUP_BY` | Dataset Column | Int |
|
|
375
|
+
| `MATCH_NUMBER` | `"match_number"` | `GAME` | `GROUP_BY` | Dataset Column | Int |
|
|
376
|
+
| `GAME_NUMBER` | `"game_number"` | `GAME` | `GROUP_BY` | Dataset Column | Int |
|
|
377
|
+
| `NUM_EVENTS` | `"num_events"` | `GAME` | `GAME_SUM` | | Int |
|
|
378
|
+
| `NUM_MATCHES` | `"num_matches"` | `GAME` | `GAME_SUM` | | Int |
|
|
379
|
+
| `NUM_GAMES` | `"num_games"` | `GAME` | `GAME_SUM` | | Int |
|
|
380
|
+
| `OPP_RANK` | `"opp_rank"` | `GAME` | `GROUP_BY` | Dataset Column (tends to be blank) | String |
|
|
381
|
+
| `MAIN_COLORS` | `"main_colors"` | `GAME` | `GROUP_BY` | Dataset Column | String |
|
|
382
|
+
| `NUM_COLORS` | `"num_colors"` | `GAME` | `GROUP_BY` | `len(MAIN_COLORS)` | Int |
|
|
383
|
+
| `SPLASH_COLORS` | `"splash_colors"` | `GAME` | `GROUP_BY` | Dataset Column | String |
|
|
384
|
+
| `HAS_SPLASH` | `"has_splash"` | `GAME` | `GROUP_BY` | | Boolean |
|
|
385
|
+
| `ON_PLAY` | `"on_play"` | `GAME` | `GROUP_BY` | Dataset Column | Boolean |
|
|
386
|
+
| `NUM_ON_PLAY` | `"num_on_play"` | `GAME` | `GAME_SUM` | | Int |
|
|
387
|
+
| `NUM_MULLIGANS` | `"num_mulligans"` | `GAME` | `GROUP_BY` | Dataset Column | Boolean |
|
|
388
|
+
| `NUM_MULLIGANS_SUM` | `"num_mulligans_sum"` | `GAME` | `GAME_SUM` | | Int |
|
|
389
|
+
| `OPP_NUM_MULLIGANS` | `"opp_num_mulligans"` | `GAME` | `GROUP_BY` | Dataset Column | Boolean |
|
|
390
|
+
| `OPP_NUM_MULLIGANS_SUM` | `"opp_num_mulligans_sum"` | `GAME` | `GAME_SUM` | | Int |
|
|
391
|
+
| `OPP_COLORS` | `"opp_colors"` | `GAME` | `GROUP_BY` | Dataset Column | Boolean |
|
|
392
|
+
| `NUM_TURNS` | `"num_turns"` | `GAME` | `GROUP_BY` | Dataset Column | Int |
|
|
393
|
+
| `NUM_TURNS_SUM` | `"num_turns_sum"` | `GAME` | `GROUP_BY` | | Int |
|
|
394
|
+
| `WON` | `"won"` | `GAME` | `GROUP_BY` | Dataset Column | Boolean |
|
|
395
|
+
| `NUM_WON` | `"num_won"` | `GAME` | `GAME_SUM` | | Int |
|
|
396
|
+
| `OPENING_HAND` | `"opening_hand"` | `GAME` | `NAME_SUM` | | Int |
|
|
397
|
+
| `WON_OPENING_HAND` | `"won_opening_hand"` | `GAME` | `NAME_SUM` | `WON * OPENING_HAND`| Int |
|
|
398
|
+
| `DRAWN` | `"drawn"` | `GAME` | `NAME_SUM` | | Int |
|
|
399
|
+
| `WON_DRAWN` | `"won_drawn"` | `GAME` | `NAME_SUM` | `WON * DRAWN`| Int |
|
|
400
|
+
| `TUTORED` | `"tutored"` | `GAME` | `NAME_SUM` | | Int |
|
|
401
|
+
| `WON_TUTORED` | `"won_tutored"` | `GAME` | `NAME_SUM` | `WON * TUTORED`| Int |
|
|
402
|
+
| `DECK` | `"deck"` | `GAME` | `NAME_SUM` | | Int |
|
|
403
|
+
| `WON_DECK` | `"won_deck"` | `GAME` | `NAME_SUM` | `WON * DECK`| Int |
|
|
404
|
+
| `SIDEBOARD` | `"sideboard"` | `GAME` | `NAME_SUM` | | Int |
|
|
405
|
+
| `WON_SIDEBOARD` | `"won_sideboard"` | `GAME` | `NAME_SUM` | `WON * SIDEBOARD`| Int |
|
|
406
|
+
| `NUM_GNS` | '"num_ns"` | `GAME` | `NAME_SUM` | `max(DECK - TUTORED - DRAWN - OPENING_HAND)` | Int |
|
|
407
|
+
| `WON_NUM_GNS` | `"won_num_gms"` | `GAME` | `NAME_SUM` | | Int |
|
|
408
|
+
| `SET_CODE` | `"set_code"` | `CARD` | `CARD_ATTR` | | String |
|
|
409
|
+
| `COLOR` | `"color"` | `CARD` | `CARD_ATTR` | | String |
|
|
410
|
+
| `RARITY` | `"rarity"` | `CARD` | `CARD_ATTR` | | String |
|
|
411
|
+
| `COLOR_IDENTITY` | `"color_identity"` | `CARD` | `CARD_ATTR` | | String |
|
|
412
|
+
| `CARD_TYPE` | `"card_type"` | `CARD` | `CARD_ATTR` | | String |
|
|
413
|
+
| `SUBTYPE` | `"subtype"` | `CARD` | `CARD_ATTR` | | String |
|
|
414
|
+
| `MANA_VALUE` | `"mana_value"` | `CARD` | `CARD_ATTR` | | Float |
|
|
415
|
+
| `MANA_COST` | `"mana_cost"` | `CARD` | `CARD_ATTR` | | String |
|
|
416
|
+
| `POWER` | `"power"` | `CARD` | `CARD_ATTR` | | Float |
|
|
417
|
+
| `TOUGHNESS` | `"toughness"` | `CARD` | `CARD_ATTR` | | Float |
|
|
418
|
+
| `IS_BONUS_SHEET` | `"is_bonus_sheet"` | `CARD` | `CARD_ATTR` | `SET_CODE` != `EXPANSION` | Boolean |
|
|
419
|
+
| `IS_DFC` | `"is_dfc"` | `CARD` | `CARD_ATTR` | Includes split cards | Boolean |
|
|
420
|
+
| `PICKED_MATCH_WR` | `"picked_match_wr"` | | `AGG` | `EVENT_MATCH_WINS` / `EVENT_MATCHES` | Float |
|
|
421
|
+
| `TROPHY_RATE` | `"trophy_rate"` | | `AGG` || Float |
|
|
422
|
+
| `GAME_WR` | `"game_wr"` | | `AGG` | `NUM_WON` / `NUM_GAMES` | Float |
|
|
423
|
+
| `ALSA` | `"alsa"` | | `AGG` | `LAST_SEEN` / `NUM_SEEN` | Float |
|
|
424
|
+
| `ATA` | `"ata"` | | `AGG` | `PICKED_AT` / `NUM_PICKED` | Float |
|
|
425
|
+
| `NUM_GP` | `"num_gp"` | | `AGG` | `DECK` | Int |
|
|
426
|
+
| `PCT_GP` | `"pct_gp"` | | `AGG` | `DECK` / (`DECK` + `SIDEBOARD`) | Float |
|
|
427
|
+
| `GP_WR` | `"gp_wr"` | | `AGG` | `WON_DECK` / `DECK` | Float |
|
|
428
|
+
| `NUM_OH` | `"num_oh"` | | `AGG` || Int |
|
|
429
|
+
| `OH_WR` | `"oh_wr"` | | `AGG` || Float |
|
|
430
|
+
| `NUM_GIH` | `"num_gih"` | | `AGG` |`OPENING_HAND` + `DRAWN`| Int |
|
|
431
|
+
| `NUM_GIH_WON` | `"num_gih_won"` | | `AGG` | `WON_OPENING_HAND` + `WON_DRAWN` | Int |
|
|
432
|
+
| `GIH_WR` | `"gih_wr"` | | `AGG` | `NUM_GIH_WON` / `NUM_GIH` | Float |
|
|
433
|
+
| `GNS_WR` | `"gns_Wr"` | | `AGG` | `WON_NUM_GNS` / `NUM_GNS` | Float |
|
|
434
|
+
| `IWD` | `"iwd"` | | `AGG` | `GIH_WR - GNS_WR` | Float |
|
|
435
|
+
| `NUM_IN_POOL` | `"num_in_pool"` | | `AGG` | `DECK` + `SIDEBOARD`| Int |
|
|
436
|
+
| `IN_POOL_WR` | `"in_pool_wr"` | | `AGG` || Float |
|
|
437
|
+
| `DECK_TOTAL` | `"deck_total"` | | `AGG` | Sum `DECK` over all rows and broadcast back to row level| Int |
|
|
438
|
+
| `WON_DECK_TOTAL` | `"won_deck_total"` | | `AGG` || Int |
|
|
439
|
+
| `GP_WR_MEAN` | `"gp_wr_mean"` | | `AGG` | `WON_DECK_TOTAL` / `DECK_TOTAL` | Float |
|
|
440
|
+
| `GP_WR_EXCESS` | `"gp_wr_excess"` | | `AGG` | `GP_WR - GP_WR_MEAN` | Float |
|
|
441
|
+
| `GP_WR_VAR` | `"gp_wr_var"` | | `AGG` | Game-weighted Variance | Float |
|
|
442
|
+
| `GP_WR_STDEV` | `"gp_wr_stdev"` | | `AGG` | Sqrt of `GP_WR_VAR` | Float |
|
|
443
|
+
| `GP_WR_Z` | `"gp_wr_z"` | | `AGG` | `GP_WR_EXCESS` / `GP_WR_STDEV` | Float |
|
|
444
|
+
| `GIH_TOTAL` | `"gih_total"` | | `AGG` | Sum `NUM_GIH` over all rows and broadcast back to row level| Float |
|
|
445
|
+
| `WON_GIH_TOTAL` | `"won_gih_total"` | | `AGG` | | Float |
|
|
446
|
+
| `GIH_WR_MEAN` | `"gih_wr_mean"` | | `AGG` | `GIH_WR - GIH_WR_MEAN` | Float |
|
|
447
|
+
| `GIH_WR_EXCESS` | `"gih_wr_excess"` | | `AGG` | `GIH_WR - GIH_WR_MEAN` | Float |
|
|
448
|
+
| `GIH_WR_VAR` | `"gih_wr_var"` | | `AGG` | Game-weighted Variance | Float |
|
|
449
|
+
| `GIH_WR_STDEV` | `"gh_wr_stdev"` | | `AGG` | Sqrt of `GIH_WR_VAR` | Float |
|
|
450
|
+
| `GIH_WR_Z` | `"gih_wr_z"` | | `AGG` |`GIH_WR_EXCESS` / `GIH_WR_STDEV` | Float |
|
|
451
|
+
|
|
452
|
+
# Roadmap to 1.0
|
|
453
|
+
|
|
454
|
+
- [ ] Support Traditional and Premier datasets (currently only Premier is supported)
|
|
455
|
+
- [ ] Enable configuration using $XDG_CONFIG_HOME/cfg.toml
|
|
456
|
+
- [ ] Support min and max aggregations over base views
|
|
457
|
+
- [ ] Enhanced profiling
|
|
458
|
+
- [ ] Optimized caching strategy
|
|
459
|
+
- [ ] Organize and analyze daily downloads from 17Lands (not a scraper!)
|
|
460
|
+
- [ ] Helper functions to generate second-order analysis by card name
|
|
461
|
+
- [ ] Helper functions for common plotting paradigms
|
|
462
|
+
- [ ] Example notebooks
|
|
463
|
+
- [ ] Scientific workflows: regression, MLE, etc
|
|
464
|
+
|
|
465
|
+
|