Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jpcbertoldo/4c6f13294d7d7e89082e6d765c8ad7db to your computer and use it in GitHub Desktop.
Save jpcbertoldo/4c6f13294d7d7e89082e6d765c8ad7db to your computer and use it in GitHub Desktop.
how many wilcoxon statistics values are there?
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 103,
"metadata": {},
"outputs": [],
"source": [
"from ast import Tuple\n",
"import itertools\n",
"from typing import List\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"ENABLE_PRINT = False\n",
"\n",
"\n",
"def recursive_print(msg, recursion):\n",
" global ENABLE_PRINT\n",
" if not ENABLE_PRINT:\n",
" return \n",
" lines = msg.split('\\n')\n",
" tabs = recursion * '\\t'\n",
" joiner = '\\n' + tabs\n",
" msg = tabs + joiner.join(lines)\n",
" print(msg)\n",
"\n",
"\n",
"# def get_tie_configs(ranks: Tuple[int, ...], recursion: int = 0) -> List[Tuple[Tuple[int, ...], ...]]:\n",
"def get_tie_configs(ranks, recursion = 0):\n",
" \"\"\"Return all the configurations of ranks considering all possible groups of ties.\n",
" \n",
" When sorting the ranks by absolute value of the differences, there are multiple ways to group the ranks into \n",
" such that there is a tie within each of them. This function finds all those possible re-groupings of ranks.\n",
" \n",
" Important: this function assumes that the ranks are consecutive and sorted, but not necessarily start at 0 (nor 1)\n",
" because it is recursive.\n",
" \n",
" Vocabulary:\n",
" \n",
" - rank: a number that represents a position in a ranking (e.g. 1, 2, 3, 4, 5) coming from the differences \n",
" of performances and sorted by absolute value\n",
" \n",
" - tie group ('tg' or 'g'): a group of ranks that are tied (e.g. if ranks 1, 2, and 3 have the same absolute difference \n",
" then they form the tie group (1, 2, 3))\n",
" \n",
" - tie group size: the number of ranks in a tie group (e.g. the tie group (1, 2, 3) has size 3)\n",
" \n",
" Note: there can be multiple tie groups at the same time (e.g. (1, 2) and (3, 4)), \n",
" and a group can have only one rank (e.g. (5,))\n",
" \n",
" - configuration: a way of grouping the ranks into tie groups (e.g. (1, 2, 3), (4,), (5,))\n",
" \n",
" Args:\n",
" ranks: a list of consecutive ranks (e.g. [1, 2, 3, 4, 5] or [3, 4, 5])\n",
" recursion (int, optional): _description_. Defaults to 0.\n",
"\n",
" \"\"\"\n",
" assert len(ranks) > 1\n",
" # ranks are sorted\n",
" assert ranks == tuple(sorted(ranks))\n",
" # all ranks are consecutive\n",
" assert ranks == tuple(range(ranks[0], ranks[-1] + 1))\n",
"\n",
" num_ranks = len(ranks)\n",
" tg_sizes = list(range(1, num_ranks + 1))\n",
" \n",
" recursive_print(f\"{num_ranks=} {ranks=} {tg_sizes=} {recursion=}\", recursion)\n",
" \n",
" possible_configs = []\n",
"\n",
" for tg_size in tg_sizes:\n",
" \n",
" # where the tie group starts\n",
" # asssume that all the ranks before it are already dealt with (i.e. they are NOT in a tie group or the possible\n",
" # tie groups have already been found and this call is recursive from what's left to the right on the list)\n",
" # the ranks after the tie group (after gidx_last) are assumed to be not yet arranged in tie groups\n",
" for tg_idx_first in range(num_ranks - tg_size + 1):\n",
" \n",
" tg_idx_last = tg_idx_first + tg_size\n",
" tg_ranks = tuple(ranks[tg_idx_first:tg_idx_last])\n",
"\n",
" # vocabulary\n",
" # idx: refers to the position of a rank inside the list of `ranks` (the arg)\n",
" \n",
" # example\n",
" # [0, 1, (2, 3, 4), 5, 6, 7, 8, 9]\n",
" # tg_size = 3\n",
" # tg_idx_last = 2 \n",
" # tg_idx_last = 5 \n",
" # tg_ranks = (2, 3, 4)\n",
" recursive_print(f\"{tg_size=} {tg_idx_first=} {tg_idx_last=} {tg_ranks=}\", recursion)\n",
"\n",
" # vocabulary\n",
" # config: a tuple of tie groups, which is a tuple of ints \n",
" # the ints that show up in the config are the ranks, and they are sorted\n",
" # example: ((1, 2, 3), (4,), (5,))\n",
"\n",
" new_config = [\n",
" (rank,) \n",
" for rank in ranks\n",
" if rank not in tg_ranks\n",
" ] + [tg_ranks]\n",
"\n",
" # makes sure that the tie groups are at the right position because it's added to the end above\n",
" new_config = tuple(sorted(new_config))\n",
" \n",
" # vocabulary\n",
" # cfg_idx: refers to the position of a tie group inside config `new_config`\n",
" tg_cfg_idx = new_config.index(tg_ranks)\n",
"\n",
" # \"sub_cfg\" means \"sub config\"\n",
" sub_cfg_upto_tg = new_config[:tg_cfg_idx + 1]\n",
" sub_cfg_after_tg = new_config[tg_cfg_idx + 1:]\n",
" \n",
" if tg_size > 1 and len(sub_cfg_after_tg) > 1:\n",
"\n",
" all_1tuples = all(len(tg) == 1 for tg in sub_cfg_after_tg)\n",
"\n",
" recursive_print(f\"\\t{new_config=}\\n\\t{tg_cfg_idx=}\\n\\t{sub_cfg_upto_tg=}\\n\\t{sub_cfg_after_tg=}\\n\\t{all_1tuples=}\", recursion)\n",
"\n",
" if all_1tuples: \n",
" \n",
" ranks_after_tg = tuple(tg_single_rank[0] for tg_single_rank in sub_cfg_after_tg)\n",
" new_config_s = [\n",
" sub_cfg_upto_tg + sub_cfg\n",
" for sub_cfg in get_tie_configs(ranks_after_tg, recursion + 1)\n",
" ]\n",
" \n",
" else:\n",
" new_config_s = [new_config]\n",
"\n",
" else:\n",
" new_config_s = [new_config]\n",
"\n",
" new_config_s = [cfg for cfg in new_config_s if cfg not in possible_configs]\n",
"\n",
" recursive_print(f\"{new_config_s=}\", recursion)\n",
"\n",
" possible_configs.extend(new_config_s)\n",
"\n",
" return possible_configs\n",
"\n",
"\n",
"# def validate_tie_config(tie_config: Tuple[Tuple[int, ...], ...]) -> Tuple[Tuple[int, ...], ...]:\n",
"def validate_tie_config(tie_config):\n",
" assert len(tie_config) > 0\n",
" assert all(len(tg) > 0 for tg in tie_config)\n",
" indices = tuple(idx for tg in tie_config for idx in tg)\n",
" # all ranks are consecutive and sorted\n",
" assert indices == tuple(range(1, 1 + len(indices)))\n",
" return tie_config\n",
"\n",
"\n",
"# def get_full_config(tie_config: Tuple[Tuple[int, ...], ...]) -> Tuple[Tuple[str, ...], ...]:\n",
"def get_full_configs(tie_config):\n",
" \"\"\"Expand the tie config to consider all the cases wether each difference of performance is + or - or 0.\n",
" \n",
" Notice that only the first tie group can be 0.\n",
" \"\"\"\n",
" \n",
" ranks = tuple(idx for tg in tie_config for idx in tg)\n",
" num_ranks = len(ranks)\n",
" num_ranks_1st_tg = len(tie_config[0])\n",
"\n",
" # the next two lists are have the combinations of signs for the differences\n",
" \n",
" # here considering there are NO zero differences\n",
" signs_combinations_nozerodiff = list(itertools.product(*(num_ranks * [(\"-\", \"+\")])))\n",
"\n",
" # if the first tie group has zero differences\n",
" signs_combinations_firstiszerodiff = [\n",
" num_ranks_1st_tg * [\"*\"] + list(sign_sublist)\n",
" for sign_sublist in itertools.product(*((num_ranks - num_ranks_1st_tg) * [(\"-\", \"+\")]))\n",
" ]\n",
" \n",
" def build_config(sign_config):\n",
" config = []\n",
" for tg in tie_config:\n",
" tg_str = []\n",
" for rank in tg:\n",
" # tg_str.append(f\"{rank}{sign_config[rank-1]}\")\n",
" tg_str.append(f\"{sign_config[rank-1]}\")\n",
" config.append(\"\".join(tg_str))\n",
" # return tuple(config)\n",
" return \" \".join(config).ljust(2 * num_ranks - 1)\n",
"\n",
" return [\n",
" build_config(sign_config_)\n",
" for sign_config_ in signs_combinations_firstiszerodiff + signs_combinations_nozerodiff\n",
" ]\n",
" \n",
"\n",
"# def validate_config(config: Tuple[Tuple[str, ...], ...]) -> Tuple[Tuple[str, ...], ...]:\n",
"def validate_config(config):\n",
" assert len(config) > 0\n",
" assert all(len(tg) > 0 for tg in config)\n",
" for gidx, group in enumerate(config):\n",
" sign = group[-1]\n",
" assert sign in ((\"+\", \"-\", \"*\") if gidx == 0 else (\"+\", \"-\"))\n",
" tie_config_str = group[:-1]\n",
" indices = tie_config_str[1:-1] # remove the parenthesis\n",
" indices = tuple(map(int, indices.split(\",\")))\n",
" validate_tie_config(indices)\n",
" return config"
]
},
{
"cell_type": "code",
"execution_count": 104,
"metadata": {},
"outputs": [],
"source": [
"ENABLE_PRINT = False\n",
"MAX_NUM_DIFF = 8\n",
"\n",
"records = [\n",
" dict(\n",
" num_diff=num_diff,\n",
" tie_configs=(tie_configs := [\n",
" validate_tie_config(tie_config)\n",
" for tie_config in get_tie_configs(tuple(range(1, 1 + num_diff)))\n",
" ]),\n",
" configs=(configs := [\n",
" cfg\n",
" for tie_cfg in tie_configs\n",
" for cfg in get_full_configs(tie_cfg)\n",
" ]),\n",
" )\n",
" for num_diff in range(2, 1 + MAX_NUM_DIFF)\n",
"]\n",
"\n",
"df = pd.DataFrame.from_records(records).set_index('num_diff')\n",
"df['num_configs'] = df['configs'].apply(lambda list_: len(list_))\n",
"df['num_configs_cumsum'] = np.cumsum(df['num_configs'])"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><div id=526cd017-c54c-4f07-8407-a1ea4cf8eae1 style=\"display:none; background-color:#9D6CFF; color:white; width:200px; height:30px; padding-left:5px; border-radius:4px; flex-direction:row; justify-content:space-around; align-items:center;\" onmouseover=\"this.style.backgroundColor='#BA9BF8'\" onmouseout=\"this.style.backgroundColor='#9D6CFF'\" onclick=\"window.commands?.execute('create-mitosheet-from-dataframe-output');\">See Full Dataframe in Mito</div> <script> if (window.commands?.hasCommand('create-mitosheet-from-dataframe-output')) document.getElementById('526cd017-c54c-4f07-8407-a1ea4cf8eae1').style.display = 'flex' </script> <table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>num_diff</th>\n",
" <th>2</th>\n",
" <th>3</th>\n",
" <th>4</th>\n",
" <th>5</th>\n",
" <th>6</th>\n",
" <th>7</th>\n",
" <th>8</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>num_configs</th>\n",
" <td>11</td>\n",
" <td>43</td>\n",
" <td>171</td>\n",
" <td>683</td>\n",
" <td>2731</td>\n",
" <td>10923</td>\n",
" <td>43691</td>\n",
" </tr>\n",
" <tr>\n",
" <th>num_configs_cumsum</th>\n",
" <td>11</td>\n",
" <td>54</td>\n",
" <td>225</td>\n",
" <td>908</td>\n",
" <td>3639</td>\n",
" <td>14562</td>\n",
" <td>58253</td>\n",
" </tr>\n",
" </tbody>\n",
"</table></div>"
],
"text/plain": [
"num_diff 2 3 4 5 6 7 8\n",
"num_configs 11 43 171 683 2731 10923 43691\n",
"num_configs_cumsum 11 54 225 908 3639 14562 58253"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"DISPLAY_COLS = ['num_configs', 'num_configs_cumsum']\n",
"df[DISPLAY_COLS].T"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "num_diff=%{x}<br>num_configs=%{y}<extra></extra>",
"legendgroup": "",
"line": {
"color": "#636efa",
"dash": "solid"
},
"marker": {
"symbol": "circle"
},
"mode": "lines",
"name": "",
"orientation": "v",
"showlegend": false,
"type": "scatter",
"x": [
2,
3,
4,
5,
6,
7,
8
],
"xaxis": "x",
"y": [
11,
43,
171,
683,
2731,
10923,
43691
],
"yaxis": "y"
}
],
"layout": {
"height": 500,
"legend": {
"tracegroupgap": 0
},
"margin": {
"t": 60
},
"template": {
"data": {
"bar": [
{
"error_x": {
"color": "#2a3f5f"
},
"error_y": {
"color": "#2a3f5f"
},
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "bar"
}
],
"barpolar": [
{
"marker": {
"line": {
"color": "#E5ECF6",
"width": 0.5
},
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "barpolar"
}
],
"carpet": [
{
"aaxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"baxis": {
"endlinecolor": "#2a3f5f",
"gridcolor": "white",
"linecolor": "white",
"minorgridcolor": "white",
"startlinecolor": "#2a3f5f"
},
"type": "carpet"
}
],
"choropleth": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "choropleth"
}
],
"contour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "contour"
}
],
"contourcarpet": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "contourcarpet"
}
],
"heatmap": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmap"
}
],
"heatmapgl": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "heatmapgl"
}
],
"histogram": [
{
"marker": {
"pattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
}
},
"type": "histogram"
}
],
"histogram2d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2d"
}
],
"histogram2dcontour": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "histogram2dcontour"
}
],
"mesh3d": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"type": "mesh3d"
}
],
"parcoords": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "parcoords"
}
],
"pie": [
{
"automargin": true,
"type": "pie"
}
],
"scatter": [
{
"fillpattern": {
"fillmode": "overlay",
"size": 10,
"solidity": 0.2
},
"type": "scatter"
}
],
"scatter3d": [
{
"line": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatter3d"
}
],
"scattercarpet": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattercarpet"
}
],
"scattergeo": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergeo"
}
],
"scattergl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattergl"
}
],
"scattermapbox": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scattermapbox"
}
],
"scatterpolar": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolar"
}
],
"scatterpolargl": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterpolargl"
}
],
"scatterternary": [
{
"marker": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"type": "scatterternary"
}
],
"surface": [
{
"colorbar": {
"outlinewidth": 0,
"ticks": ""
},
"colorscale": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"type": "surface"
}
],
"table": [
{
"cells": {
"fill": {
"color": "#EBF0F8"
},
"line": {
"color": "white"
}
},
"header": {
"fill": {
"color": "#C8D4E3"
},
"line": {
"color": "white"
}
},
"type": "table"
}
]
},
"layout": {
"annotationdefaults": {
"arrowcolor": "#2a3f5f",
"arrowhead": 0,
"arrowwidth": 1
},
"autotypenumbers": "strict",
"coloraxis": {
"colorbar": {
"outlinewidth": 0,
"ticks": ""
}
},
"colorscale": {
"diverging": [
[
0,
"#8e0152"
],
[
0.1,
"#c51b7d"
],
[
0.2,
"#de77ae"
],
[
0.3,
"#f1b6da"
],
[
0.4,
"#fde0ef"
],
[
0.5,
"#f7f7f7"
],
[
0.6,
"#e6f5d0"
],
[
0.7,
"#b8e186"
],
[
0.8,
"#7fbc41"
],
[
0.9,
"#4d9221"
],
[
1,
"#276419"
]
],
"sequential": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
],
"sequentialminus": [
[
0,
"#0d0887"
],
[
0.1111111111111111,
"#46039f"
],
[
0.2222222222222222,
"#7201a8"
],
[
0.3333333333333333,
"#9c179e"
],
[
0.4444444444444444,
"#bd3786"
],
[
0.5555555555555556,
"#d8576b"
],
[
0.6666666666666666,
"#ed7953"
],
[
0.7777777777777778,
"#fb9f3a"
],
[
0.8888888888888888,
"#fdca26"
],
[
1,
"#f0f921"
]
]
},
"colorway": [
"#636efa",
"#EF553B",
"#00cc96",
"#ab63fa",
"#FFA15A",
"#19d3f3",
"#FF6692",
"#B6E880",
"#FF97FF",
"#FECB52"
],
"font": {
"color": "#2a3f5f"
},
"geo": {
"bgcolor": "white",
"lakecolor": "white",
"landcolor": "#E5ECF6",
"showlakes": true,
"showland": true,
"subunitcolor": "white"
},
"hoverlabel": {
"align": "left"
},
"hovermode": "closest",
"mapbox": {
"style": "light"
},
"paper_bgcolor": "white",
"plot_bgcolor": "#E5ECF6",
"polar": {
"angularaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"radialaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"scene": {
"xaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"yaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
},
"zaxis": {
"backgroundcolor": "#E5ECF6",
"gridcolor": "white",
"gridwidth": 2,
"linecolor": "white",
"showbackground": true,
"ticks": "",
"zerolinecolor": "white"
}
},
"shapedefaults": {
"line": {
"color": "#2a3f5f"
}
},
"ternary": {
"aaxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"baxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
},
"bgcolor": "#E5ECF6",
"caxis": {
"gridcolor": "white",
"linecolor": "white",
"ticks": ""
}
},
"title": {
"x": 0.05
},
"xaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
},
"yaxis": {
"automargin": true,
"gridcolor": "white",
"linecolor": "white",
"ticks": "",
"title": {
"standoff": 15
},
"zerolinecolor": "white",
"zerolinewidth": 2
}
}
},
"width": 500,
"xaxis": {
"anchor": "y",
"domain": [
0,
1
],
"title": {
"text": "num_diff"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "num_configs"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import plotly.express as px\n",
"fig = px.line(df.reset_index(), x='num_diff', y='num_configs').update_layout(width=500, height=500)\n",
"fig"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[((1,), (2,), (3,)), ((1, 2), (3,)), ((1,), (2, 3)), ((1, 2, 3),)]"
]
},
"execution_count": 107,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[3].tie_configs"
]
},
{
"cell_type": "code",
"execution_count": 108,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['* - -',\n",
" '* - +',\n",
" '* + -',\n",
" '* + +',\n",
" '- - -',\n",
" '- - +',\n",
" '- + -',\n",
" '- + +',\n",
" '+ - -',\n",
" '+ - +',\n",
" '+ + -',\n",
" '+ + +',\n",
" '** - ',\n",
" '** + ',\n",
" '-- - ',\n",
" '-- + ',\n",
" '-+ - ',\n",
" '-+ + ',\n",
" '+- - ',\n",
" '+- + ',\n",
" '++ - ',\n",
" '++ + ',\n",
" '* -- ',\n",
" '* -+ ',\n",
" '* +- ',\n",
" '* ++ ',\n",
" '- -- ',\n",
" '- -+ ',\n",
" '- +- ',\n",
" '- ++ ',\n",
" '+ -- ',\n",
" '+ -+ ',\n",
" '+ +- ',\n",
" '+ ++ ',\n",
" '*** ',\n",
" '--- ',\n",
" '--+ ',\n",
" '-+- ',\n",
" '-++ ',\n",
" '+-- ',\n",
" '+-+ ',\n",
" '++- ',\n",
" '+++ ']"
]
},
"execution_count": 108,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[3].configs"
]
},
{
"cell_type": "code",
"execution_count": 109,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[((1,), (2,), (3,), (4,)),\n",
" ((1, 2), (3,), (4,)),\n",
" ((1, 2), (3, 4)),\n",
" ((1,), (2, 3), (4,)),\n",
" ((1,), (2,), (3, 4)),\n",
" ((1, 2, 3), (4,)),\n",
" ((1,), (2, 3, 4)),\n",
" ((1, 2, 3, 4),)]"
]
},
"execution_count": 109,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[4].tie_configs"
]
},
{
"cell_type": "code",
"execution_count": 110,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[((1,), (2,), (3,), (4,), (5,)),\n",
" ((1, 2), (3,), (4,), (5,)),\n",
" ((1, 2), (3, 4), (5,)),\n",
" ((1, 2), (3,), (4, 5)),\n",
" ((1, 2), (3, 4, 5)),\n",
" ((1,), (2, 3), (4,), (5,)),\n",
" ((1,), (2, 3), (4, 5)),\n",
" ((1,), (2,), (3, 4), (5,)),\n",
" ((1,), (2,), (3,), (4, 5)),\n",
" ((1, 2, 3), (4,), (5,)),\n",
" ((1, 2, 3), (4, 5)),\n",
" ((1,), (2, 3, 4), (5,)),\n",
" ((1,), (2,), (3, 4, 5)),\n",
" ((1, 2, 3, 4), (5,)),\n",
" ((1,), (2, 3, 4, 5)),\n",
" ((1, 2, 3, 4, 5),)]"
]
},
"execution_count": 110,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.loc[5].tie_configs"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "genv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.15"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "dbefe0203beb0481e6605383038aac293a16213add0aaad9c445996a9034b637"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment