arthur-common 2.1.47__py3-none-any.whl → 2.1.49__py3-none-any.whl
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 arthur-common might be problematic. Click here for more details.
- arthur_common/aggregations/functions/confusion_matrix.py +10 -6
- arthur_common/models/connectors.py +2 -0
- {arthur_common-2.1.47.dist-info → arthur_common-2.1.49.dist-info}/METADATA +1 -1
- {arthur_common-2.1.47.dist-info → arthur_common-2.1.49.dist-info}/RECORD +5 -5
- {arthur_common-2.1.47.dist-info → arthur_common-2.1.49.dist-info}/WHEEL +0 -0
|
@@ -13,7 +13,7 @@ from arthur_common.models.schema_definitions import (
|
|
|
13
13
|
ScalarType,
|
|
14
14
|
ScopeSchemaTag,
|
|
15
15
|
)
|
|
16
|
-
from arthur_common.tools.duckdb_data_loader import escape_identifier
|
|
16
|
+
from arthur_common.tools.duckdb_data_loader import escape_identifier, escape_str_literal
|
|
17
17
|
from duckdb import DuckDBPyConnection
|
|
18
18
|
|
|
19
19
|
|
|
@@ -57,7 +57,8 @@ class ConfusionMatrixAggregationFunction(NumericAggregationFunction):
|
|
|
57
57
|
SUM(CASE WHEN prediction = actual_value AND actual_value = 1 THEN 1 ELSE 0 END) AS true_positive_count,
|
|
58
58
|
SUM(CASE WHEN prediction != actual_value AND actual_value = 0 THEN 1 ELSE 0 END) AS false_positive_count,
|
|
59
59
|
SUM(CASE WHEN prediction != actual_value AND actual_value = 1 THEN 1 ELSE 0 END) AS false_negative_count,
|
|
60
|
-
SUM(CASE WHEN prediction = actual_value AND actual_value = 0 THEN 1 ELSE 0 END) AS true_negative_count
|
|
60
|
+
SUM(CASE WHEN prediction = actual_value AND actual_value = 0 THEN 1 ELSE 0 END) AS true_negative_count,
|
|
61
|
+
{escaped_prediction_col_name} as prediction_column_name
|
|
61
62
|
FROM normalized_data
|
|
62
63
|
GROUP BY ts
|
|
63
64
|
ORDER BY ts
|
|
@@ -65,6 +66,7 @@ class ConfusionMatrixAggregationFunction(NumericAggregationFunction):
|
|
|
65
66
|
segmentation_cols = [] if not segmentation_cols else segmentation_cols
|
|
66
67
|
escaped_timestamp_col = escape_identifier(timestamp_col)
|
|
67
68
|
escaped_prediction_col = escape_identifier(prediction_col)
|
|
69
|
+
escaped_prediction_col_name = escape_str_literal(prediction_col)
|
|
68
70
|
escaped_gt_values_col = escape_identifier(gt_values_col)
|
|
69
71
|
# build query components with segmentation columns
|
|
70
72
|
escaped_segmentation_cols = [
|
|
@@ -81,8 +83,10 @@ class ConfusionMatrixAggregationFunction(NumericAggregationFunction):
|
|
|
81
83
|
"SUM(CASE WHEN prediction != actual_value AND actual_value = 0 THEN 1 ELSE 0 END) AS false_positive_count",
|
|
82
84
|
"SUM(CASE WHEN prediction != actual_value AND actual_value = 1 THEN 1 ELSE 0 END) AS false_negative_count",
|
|
83
85
|
"SUM(CASE WHEN prediction = actual_value AND actual_value = 0 THEN 1 ELSE 0 END) AS true_negative_count",
|
|
86
|
+
f"{escaped_prediction_col_name} as prediction_column_name",
|
|
84
87
|
] + escaped_segmentation_cols
|
|
85
88
|
second_subquery_group_by_cols = ["ts"] + escaped_segmentation_cols
|
|
89
|
+
extra_dims = ["prediction_column_name"]
|
|
86
90
|
|
|
87
91
|
# build query
|
|
88
92
|
confusion_matrix_query = f"""
|
|
@@ -102,25 +106,25 @@ class ConfusionMatrixAggregationFunction(NumericAggregationFunction):
|
|
|
102
106
|
tp = self.group_query_results_to_numeric_metrics(
|
|
103
107
|
results,
|
|
104
108
|
"true_positive_count",
|
|
105
|
-
dim_columns=segmentation_cols,
|
|
109
|
+
dim_columns=segmentation_cols + extra_dims,
|
|
106
110
|
timestamp_col="ts",
|
|
107
111
|
)
|
|
108
112
|
fp = self.group_query_results_to_numeric_metrics(
|
|
109
113
|
results,
|
|
110
114
|
"false_positive_count",
|
|
111
|
-
dim_columns=segmentation_cols,
|
|
115
|
+
dim_columns=segmentation_cols + extra_dims,
|
|
112
116
|
timestamp_col="ts",
|
|
113
117
|
)
|
|
114
118
|
fn = self.group_query_results_to_numeric_metrics(
|
|
115
119
|
results,
|
|
116
120
|
"false_negative_count",
|
|
117
|
-
dim_columns=segmentation_cols,
|
|
121
|
+
dim_columns=segmentation_cols + extra_dims,
|
|
118
122
|
timestamp_col="ts",
|
|
119
123
|
)
|
|
120
124
|
tn = self.group_query_results_to_numeric_metrics(
|
|
121
125
|
results,
|
|
122
126
|
"true_negative_count",
|
|
123
|
-
dim_columns=segmentation_cols,
|
|
127
|
+
dim_columns=segmentation_cols + extra_dims,
|
|
124
128
|
timestamp_col="ts",
|
|
125
129
|
)
|
|
126
130
|
tp_metric = self.series_to_metric("confusion_matrix_true_positive_count", tp)
|
|
@@ -35,6 +35,8 @@ MSSQL_CONNECTOR_DATABASE_FIELD = "database"
|
|
|
35
35
|
MSSQL_CONNECTOR_USERNAME_FIELD = "username"
|
|
36
36
|
MSSQL_CONNECTOR_PASSWORD_FIELD = "password"
|
|
37
37
|
MSSQL_CONNECTOR_DRIVER_FIELD = "driver"
|
|
38
|
+
MSSQL_CONNECTOR_TABLE_NAME_FIELD = "table_name"
|
|
39
|
+
|
|
38
40
|
|
|
39
41
|
# dataset (connector type dependent) constants
|
|
40
42
|
SHIELD_DATASET_TASK_ID_FIELD = "task_id"
|
|
@@ -4,7 +4,7 @@ arthur_common/aggregations/aggregator.py,sha256=8J0TRYjQdwf0qXBnoZ4ETJVCdo4UIyvQ
|
|
|
4
4
|
arthur_common/aggregations/functions/README.md,sha256=MkZoTAJ94My96R5Z8GAxud7S6vyR0vgVi9gqdt9a4XY,5460
|
|
5
5
|
arthur_common/aggregations/functions/__init__.py,sha256=HqC3UNRURX7ZQHgamTrQvfA8u_FiZGZ4I4eQW7Ooe5o,1299
|
|
6
6
|
arthur_common/aggregations/functions/categorical_count.py,sha256=W0xIpqqSElRpGBPpvztoZBpDO5QtiGYpaMVOQ3piS-4,5077
|
|
7
|
-
arthur_common/aggregations/functions/confusion_matrix.py,sha256=
|
|
7
|
+
arthur_common/aggregations/functions/confusion_matrix.py,sha256=fZ5SeFcENjGyoCqecRTF9Y0Ub-RzsA-SlZ8cEHzUvnM,21111
|
|
8
8
|
arthur_common/aggregations/functions/inference_count.py,sha256=jIhuh_NjL82NA84qJD2VI3FVRgZCSFjfcME3Hr_slpg,3832
|
|
9
9
|
arthur_common/aggregations/functions/inference_count_by_class.py,sha256=JKTOhXSP3hBz28u10AvA8OyDi7P68Fv7NP6j_M7kXCQ,11066
|
|
10
10
|
arthur_common/aggregations/functions/inference_null_count.py,sha256=l-yuVX7OJQGk-vvnkuXJPD-mEI1ZzwGjbzeihwSDT_M,4566
|
|
@@ -18,7 +18,7 @@ arthur_common/aggregations/functions/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeR
|
|
|
18
18
|
arthur_common/aggregations/functions/shield_aggregations.py,sha256=nkMlj9V7NIKeRP46jpsrlfB741RHk2CgwimD7BYp9To,31540
|
|
19
19
|
arthur_common/aggregations/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
arthur_common/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
arthur_common/models/connectors.py,sha256=
|
|
21
|
+
arthur_common/models/connectors.py,sha256=iQ9J--krb7p8zMQ_AvOaazSRupQKqpr_9ikCcuQkDtU,1848
|
|
22
22
|
arthur_common/models/datasets.py,sha256=giG_8mv_3ilBf7cIvRV0_TDCDdb4qxRbYZvl7hRb6l8,491
|
|
23
23
|
arthur_common/models/metrics.py,sha256=ZfsDL3aPdhZ1-E1-wlRyZT4lZNzz2A3qL-jDrqJbQdY,8217
|
|
24
24
|
arthur_common/models/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -34,6 +34,6 @@ arthur_common/tools/functions.py,sha256=FWL4eWO5-vLp86WudT-MGUKvf2B8f02IdoXQFKd6
|
|
|
34
34
|
arthur_common/tools/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
arthur_common/tools/schema_inferer.py,sha256=PkAOHZRk_rZ1OZSigYrfzH-jERb9B_Gu7pOMl9WJQA8,4202
|
|
36
36
|
arthur_common/tools/time_utils.py,sha256=4gfiu9NXfvPZltiVNLSIQGylX6h2W0viNi9Kv4bKyfw,1410
|
|
37
|
-
arthur_common-2.1.
|
|
38
|
-
arthur_common-2.1.
|
|
39
|
-
arthur_common-2.1.
|
|
37
|
+
arthur_common-2.1.49.dist-info/METADATA,sha256=KcHRIA8akOMXT7eLagd5CBe_RzdwDFeSXVQuOUp2fTU,1568
|
|
38
|
+
arthur_common-2.1.49.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
39
|
+
arthur_common-2.1.49.dist-info/RECORD,,
|
|
File without changes
|