Compare commits

...

4 Commits

Author SHA1 Message Date
Oscar Plaisant
eabe42c73f small visual changes 2024-07-03 20:49:24 +02:00
Oscar Plaisant
74d25bd985 beter data indentation 2024-07-02 15:32:55 +02:00
Oscar Plaisant
b97029d090 add documentation 2024-07-02 03:58:06 +02:00
Oscar Plaisant
b13c75542b add comment 2024-07-02 03:57:48 +02:00
6 changed files with 360 additions and 326 deletions

View File

@@ -8,6 +8,7 @@ all: execute-script
execute-script: requirements.txt
source bin/activate && python3 src/concentration_test.py;
# Install the required python packages
requirements.txt:
bin/pip3 install -r requirements.txt

View File

@@ -1,11 +1,41 @@
# Description of the project
## General informations
The execution is managed via the Makefile.
The python environment is managed via a virtual environment. Its configuration is standard.
If you need to install a new python package, add it to the `requirements.txt` file (using pip syntax). It shoule be installed automatically when you execute the project. Anyway, you can run `make requirements.txt`
The installation of new databases (from csv) is managed in the Makefile.
# Configuration
The configuration is stored the the `src/config.yaml` file.
## Database-specific configuration
`database_name` should contain the name of the database to use. The database has to be stored in the proper directory structure (See the [Directory structure > Datasets](README.md#datasets))
`database_name` should contain the name of the database to use. The database has to be stored in the proper directory structure (See the [Directory structure > Datasets](README.md#datasets)). This parameter is case sensitive.
Each database can have a separated and independent config.
It is inside the key name like the database.
For example, the database named `SSB` has its configuration under the `SSB:` key (and this configuration will be used only when `database_name` is `SSB`).
The following table explains every parameter that is used in the database specific configuration.
| key | type | usage |
| --- | ---- | ----- |
| `orders_length` | integer | The length of considered orderings |
| `hypothesis_ordering` | list[str] | The ordering to test the correctness of |
| `parameter` | str | The "parameter" attribute in the query (an attribute in the database). |
| `authorized_parameter_values` | list[str] | The restriction over possibles values in the query's orderings (`WHERE parameter IN authorized_parameter_values`). |
| `summed_attribute` | str | The database attribute that is summed in the aggregation, and used to order the values. |
| `criterion` | list[str] | The list of possibles values for the criteria in the query. When getting a random query, one of these values is chosen randomly for the criteria. |
The `query_generator` key is a parameter containing the name of the query-generator object that is used when building the query. You should not modify this unless you modify the code accordingly.
# Directory structure of the project

View File

@@ -1,323 +1,325 @@
data = [
(10, 3.2814),
(10, 1.1246),
(10, 1.2786),
(10, 1.4048),
(10, 1.321),
(10, 1.0877),
(10, 1.3789),
(10, 1.2656),
(10, 1.2232),
(10, 1.1576),
(10, 1.0716),
(10, 1.1329),
(10, 1.2229),
(10, 1.0674),
(10, 1.1904),
(10, 1.1503),
(10, 1.1237),
(10, 1.0695),
(10, 1.192),
(10, 1.1163),
(2, 4.985),
(2, 3.4106),
(2, 4.4639),
(2, 3.8917),
(2, 3.5325),
(2, 3.6275),
(2, 3.586),
(2, 3.7085),
(2, 3.5506),
(2, 3.882),
(2, 3.4114),
(2, 2.9221),
(2, 3.0728),
(2, 3.2228),
(2, 3.126),
(2, 3.018),
(2, 2.6121),
(2, 3.3835),
(2, 2.688),
(2, 2.7131),
(3, 4.9138),
(3, 3.6681),
(3, 4.228),
(3, 4.2168),
(3, 3.6797),
(3, 3.2504),
(3, 3.3086),
(3, 3.8523),
(3, 3.4246),
(3, 3.3924),
(3, 3.4794),
(3, 3.3593),
(3, 3.7011),
(3, 3.8801),
(3, 3.6497),
(3, 3.4457),
(3, 3.1876),
(3, 3.3091),
(3, 3.2624),
(3, 3.1918),
(4, 3.996),
(4, 2.3734),
(4, 2.3895),
(4, 2.027),
(4, 2.0217),
(4, 1.9908),
(4, 2.0311),
(4, 1.9258),
(4, 2.0102),
(4, 2.0338),
(4, 2.0078),
(4, 2.0199),
(4, 1.9693),
(4, 2.0876),
(4, 1.9746),
(4, 2.1291),
(4, 2.0353),
(4, 2.0223),
(4, 1.9693),
(4, 2.1176),
(5, 3.6458),
(5, 1.9484),
(5, 2.0161),
(5, 1.999),
(5, 1.9481),
(5, 2.0306),
(5, 2.0121),
(5, 2.0052),
(5, 1.9338),
(5, 1.9788),
(5, 1.8997),
(5, 2.0425),
(5, 2.009),
(5, 2.0407),
(5, 2.5651),
(5, 2.3494),
(5, 4.0412),
(5, 2.3624),
(5, 2.1484),
(5, 2.1279),
(6, 3.0398),
(6, 1.3934),
(6, 1.5696),
(6, 1.3557),
(6, 1.5808),
(6, 1.2172),
(6, 1.4345),
(6, 1.2293),
(6, 1.1803),
(6, 1.5682),
(6, 1.2226),
(6, 1.3786),
(6, 1.1973),
(6, 1.2538),
(6, 1.326),
(6, 1.285),
(6, 1.4086),
(6, 1.4677),
(6, 1.325),
(6, 1.7864),
(6, 2.8935),
(6, 1.4145),
(6, 1.2627),
(6, 1.2306),
(6, 1.4593),
(6, 1.4569),
(6, 1.4273),
(6, 1.2546),
(6, 1.8061),
(6, 1.7507),
(6, 1.8094),
(6, 1.6604),
(6, 1.1203),
(6, 1.5539),
(6, 1.1841),
(6, 1.3447),
(6, 1.318),
(6, 1.2145),
(6, 1.5093),
(6, 1.222),
(7, 2.8026),
(7, 1.2677),
(7, 1.3518),
(7, 1.2646),
(7, 1.3529),
(7, 1.298),
(7, 1.3879),
(7, 1.5377),
(7, 1.6141),
(7, 1.6608),
(7, 1.6938),
(7, 1.5475),
(7, 1.3327),
(7, 1.3387),
(7, 1.3543),
(7, 1.3318),
(7, 1.2613),
(7, 1.3656),
(7, 1.3646),
(7, 1.3082),
(7, 3.7757),
(7, 1.2824),
(7, 1.4717),
(7, 1.3426),
(7, 1.3604),
(7, 1.3191),
(7, 1.3851),
(7, 1.4107),
(7, 1.3291),
(7, 1.3861),
(7, 1.2749),
(7, 1.3441),
(7, 1.2875),
(7, 1.285),
(7, 1.4011),
(7, 1.285),
(7, 1.4398),
(7, 1.3175),
(7, 1.1406),
(7, 1.1148),
(7, 2.9924),
(7, 1.3008),
(7, 1.3184),
(7, 1.3205),
(7, 1.3085),
(7, 1.3275),
(7, 1.3117),
(7, 1.2819),
(7, 1.3389),
(7, 1.3741),
(7, 1.3308),
(7, 1.2763),
(7, 1.3069),
(7, 1.3578),
(7, 1.3264),
(7, 1.3716),
(7, 1.2968),
(7, 1.3645),
(7, 1.3726),
(7, 1.1437),
(7, 2.8074),
(7, 1.2116),
(7, 1.2206),
(7, 1.3141),
(7, 1.1898),
(7, 1.3442),
(7, 1.1675),
(7, 1.4256),
(7, 1.2796),
(7, 1.3477),
(7, 1.3515),
(7, 1.0426),
(7, 1.2668),
(7, 1.3067),
(7, 1.342),
(7, 1.2743),
(7, 1.3513),
(7, 1.6219),
(7, 1.6259),
(7, 1.6586),
(8, 2.7135),
(8, 1.0404),
(8, 1.2629),
(8, 1.0612),
(8, 1.1745),
(8, 1.1316),
(8, 0.9676),
(8, 1.1561),
(8, 0.9848),
(8, 1.1405),
(8, 1.1975),
(8, 1.0905),
(8, 1.3382),
(8, 1.2419),
(8, 1.221),
(8, 1.2209),
(8, 1.2595),
(8, 1.2315),
(8, 1.1985),
(8, 1.5726),
(8, 2.9819),
(8, 1.1447),
(8, 1.4281),
(8, 1.5031),
(8, 1.4433),
(8, 1.7052),
(8, 1.611),
(8, 1.3322),
(8, 1.2052),
(8, 1.3051),
(8, 1.0381),
(8, 1.1987),
(8, 1.1742),
(8, 1.2184),
(8, 0.9659),
(8, 1.0336),
(8, 1.2008),
(8, 1.23),
(8, 1.1227),
(8, 1.084),
(8, 3.4243),
(8, 1.5459),
(8, 1.705),
(8, 1.4039),
(8, 1.1903),
(8, 1.1655),
(8, 1.1943),
(8, 1.2169),
(8, 1.1924),
(8, 1.2306),
(8, 1.1635),
(8, 1.1598),
(8, 1.2742),
(8, 1.1646),
(8, 1.034),
(8, 1.2087),
(8, 1.1515),
(8, 1.145),
(8, 1.2855),
(8, 1.0425),
(8, 2.9917),
(8, 1.2165),
(8, 1.187),
(8, 1.1772),
(8, 1.2726),
(8, 1.1411),
(8, 1.2505),
(8, 1.2163),
(8, 1.2172),
(8, 1.1765),
(8, 1.2291),
(8, 1.2302),
(8, 1.195),
(8, 1.3805),
(8, 1.4443),
(8, 1.4463),
(8, 1.535),
(8, 1.5171),
(8, 1.2004),
(8, 1.2866),
(8, 2.9194),
(8, 1.1209),
(8, 1.1777),
(8, 1.1953),
(8, 1.3267),
(8, 1.2001),
(8, 1.2174),
(8, 1.1995),
(8, 1.294),
(8, 1.1856),
(8, 1.1948),
(8, 1.235),
(8, 1.1608),
(8, 1.2643),
(8, 1.3034),
(8, 1.5058),
(8, 1.4037),
(8, 1.6096),
(8, 1.4336),
(8, 1.3659),
(10, 3.2814),
(10, 1.1246),
(10, 1.2786),
(10, 1.4048),
(10, 1.321),
(10, 1.0877),
(10, 1.3789),
(10, 1.2656),
(10, 1.2232),
(10, 1.1576),
(10, 1.0716),
(10, 1.1329),
(10, 1.2229),
(10, 1.0674),
(10, 1.1904),
(10, 1.1503),
(10, 1.1237),
(10, 1.0695),
(10, 1.192),
(10, 1.1163),
(2, 4.985),
(2, 3.4106),
(2, 4.4639),
(2, 3.8917),
(2, 3.5325),
(2, 3.6275),
(2, 3.586),
(2, 3.7085),
(2, 3.5506),
(2, 3.882),
(2, 3.4114),
(2, 2.9221),
(2, 3.0728),
(2, 3.2228),
(2, 3.126),
(2, 3.018),
(2, 2.6121),
(2, 3.3835),
(2, 2.688),
(2, 2.7131),
(3, 4.9138),
(3, 3.6681),
(3, 4.228),
(3, 4.2168),
(3, 3.6797),
(3, 3.2504),
(3, 3.3086),
(3, 3.8523),
(3, 3.4246),
(3, 3.3924),
(3, 3.4794),
(3, 3.3593),
(3, 3.7011),
(3, 3.8801),
(3, 3.6497),
(3, 3.4457),
(3, 3.1876),
(3, 3.3091),
(3, 3.2624),
(3, 3.1918),
(4, 3.996),
(4, 2.3734),
(4, 2.3895),
(4, 2.027),
(4, 2.0217),
(4, 1.9908),
(4, 2.0311),
(4, 1.9258),
(4, 2.0102),
(4, 2.0338),
(4, 2.0078),
(4, 2.0199),
(4, 1.9693),
(4, 2.0876),
(4, 1.9746),
(4, 2.1291),
(4, 2.0353),
(4, 2.0223),
(4, 1.9693),
(4, 2.1176),
(5, 3.6458),
(5, 1.9484),
(5, 2.0161),
(5, 1.999),
(5, 1.9481),
(5, 2.0306),
(5, 2.0121),
(5, 2.0052),
(5, 1.9338),
(5, 1.9788),
(5, 1.8997),
(5, 2.0425),
(5, 2.009),
(5, 2.0407),
(5, 2.5651),
(5, 2.3494),
(5, 4.0412),
(5, 2.3624),
(5, 2.1484),
(5, 2.1279),
(6, 3.0398),
(6, 1.3934),
(6, 1.5696),
(6, 1.3557),
(6, 1.5808),
(6, 1.2172),
(6, 1.4345),
(6, 1.2293),
(6, 1.1803),
(6, 1.5682),
(6, 1.2226),
(6, 1.3786),
(6, 1.1973),
(6, 1.2538),
(6, 1.326),
(6, 1.285),
(6, 1.4086),
(6, 1.4677),
(6, 1.325),
(6, 1.7864),
(6, 2.8935),
(6, 1.4145),
(6, 1.2627),
(6, 1.2306),
(6, 1.4593),
(6, 1.4569),
(6, 1.4273),
(6, 1.2546),
(6, 1.8061),
(6, 1.7507),
(6, 1.8094),
(6, 1.6604),
(6, 1.1203),
(6, 1.5539),
(6, 1.1841),
(6, 1.3447),
(6, 1.318),
(6, 1.2145),
(6, 1.5093),
(6, 1.222),
(7, 2.8026),
(7, 1.2677),
(7, 1.3518),
(7, 1.2646),
(7, 1.3529),
(7, 1.298),
(7, 1.3879),
(7, 1.5377),
(7, 1.6141),
(7, 1.6608),
(7, 1.6938),
(7, 1.5475),
(7, 1.3327),
(7, 1.3387),
(7, 1.3543),
(7, 1.3318),
(7, 1.2613),
(7, 1.3656),
(7, 1.3646),
(7, 1.3082),
(7, 3.7757),
(7, 1.2824),
(7, 1.4717),
(7, 1.3426),
(7, 1.3604),
(7, 1.3191),
(7, 1.3851),
(7, 1.4107),
(7, 1.3291),
(7, 1.3861),
(7, 1.2749),
(7, 1.3441),
(7, 1.2875),
(7, 1.285),
(7, 1.4011),
(7, 1.285),
(7, 1.4398),
(7, 1.3175),
(7, 1.1406),
(7, 1.1148),
(7, 2.9924),
(7, 1.3008),
(7, 1.3184),
(7, 1.3205),
(7, 1.3085),
(7, 1.3275),
(7, 1.3117),
(7, 1.2819),
(7, 1.3389),
(7, 1.3741),
(7, 1.3308),
(7, 1.2763),
(7, 1.3069),
(7, 1.3578),
(7, 1.3264),
(7, 1.3716),
(7, 1.2968),
(7, 1.3645),
(7, 1.3726),
(7, 1.1437),
(7, 2.8074),
(7, 1.2116),
(7, 1.2206),
(7, 1.3141),
(7, 1.1898),
(7, 1.3442),
(7, 1.1675),
(7, 1.4256),
(7, 1.2796),
(7, 1.3477),
(7, 1.3515),
(7, 1.0426),
(7, 1.2668),
(7, 1.3067),
(7, 1.342),
(7, 1.2743),
(7, 1.3513),
(7, 1.6219),
(7, 1.6259),
(7, 1.6586),
(8, 2.7135),
(8, 1.0404),
(8, 1.2629),
(8, 1.0612),
(8, 1.1745),
(8, 1.1316),
(8, 0.9676),
(8, 1.1561),
(8, 0.9848),
(8, 1.1405),
(8, 1.1975),
(8, 1.0905),
(8, 1.3382),
(8, 1.2419),
(8, 1.221),
(8, 1.2209),
(8, 1.2595),
(8, 1.2315),
(8, 1.1985),
(8, 1.5726),
(8, 2.9819),
(8, 1.1447),
(8, 1.4281),
(8, 1.5031),
(8, 1.4433),
(8, 1.7052),
(8, 1.611),
(8, 1.3322),
(8, 1.2052),
(8, 1.3051),
(8, 1.0381),
(8, 1.1987),
(8, 1.1742),
(8, 1.2184),
(8, 0.9659),
(8, 1.0336),
(8, 1.2008),
(8, 1.23),
(8, 1.1227),
(8, 1.084),
(8, 3.4243),
(8, 1.5459),
(8, 1.705),
(8, 1.4039),
(8, 1.1903),
(8, 1.1655),
(8, 1.1943),
(8, 1.2169),
(8, 1.1924),
(8, 1.2306),
(8, 1.1635),
(8, 1.1598),
(8, 1.2742),
(8, 1.1646),
(8, 1.034),
(8, 1.2087),
(8, 1.1515),
(8, 1.145),
(8, 1.2855),
(8, 1.0425),
(8, 2.9917),
(8, 1.2165),
(8, 1.187),
(8, 1.1772),
(8, 1.2726),
(8, 1.1411),
(8, 1.2505),
(8, 1.2163),
(8, 1.2172),
(8, 1.1765),
(8, 1.2291),
(8, 1.2302),
(8, 1.195),
(8, 1.3805),
(8, 1.4443),
(8, 1.4463),
(8, 1.535),
(8, 1.5171),
(8, 1.2004),
(8, 1.2866),
(8, 2.9194),
(8, 1.1209),
(8, 1.1777),
(8, 1.1953),
(8, 1.3267),
(8, 1.2001),
(8, 1.2174),
(8, 1.1995),
(8, 1.294),
(8, 1.1856),
(8, 1.1948),
(8, 1.235),
(8, 1.1608),
(8, 1.2643),
(8, 1.3034),
(8, 1.5058),
(8, 1.4037),
(8, 1.6096),
(8, 1.4336),
(8, 1.3659)
]

View File

@@ -23,7 +23,8 @@ from tprint import tprint
def kendall_tau_dist(ranking_a: list[int], ranking_b: list[int]) -> Number:
"""The kendall τ distance between two rankings / permutations.
It is the number of inversions that don't have the same sign within all pairs of an inversion of ranking_a and an inversion of ranking_b.
It is the number of inversions that don't have the same sign within all
pairs of an inversion of ranking_a and an inversion of ranking_b.
"""
ranking_a = np.array(ranking_a)
ranking_b = np.array(ranking_b)

View File

@@ -58,7 +58,7 @@ def get_orderings_from_table(table: np.ndarray, column_index: int = 0) -> list:
return values[np.sort(indexes)] # distinct ordered values
def get_all_orderings_from_table(table: list[list[str]]) -> dict:
def get_all_orderings_from_table(table: list[list[str]]) -> dict[str, list[str]]:
"""Return a dictionnary mapping a value of the criteria to the order you
get when selecting on this value.
This means you get all orders of a table, where the criteria is in the

View File

@@ -4,7 +4,7 @@ from fastcache import lru_cache
Number = int | float
# @lru_cache(maxsize=16)
@lru_cache(maxsize=4)
def combinations_of_2(size: int):
"""Returns an array of size n*2, containing every pair of two integers
smaller than size, but not listing twice the pairs with the same numbers
@@ -21,7 +21,7 @@ def __combinations_of_2(size: int):
"""Compiled helper."""
# return np.array(list(combinations(range(size), 2)))
# return np.array(np.meshgrid(np.arange(size), np.arange(size))).T.reshape(-1, 2)
return np.array([[i, j] for i in range(0, size) for j in range(0, size) if i<j])
return np.array([[i, j] for i in range(size) for j in range(size) if i<j])