gitlabds 2.2.0__tar.gz → 2.2.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.
- {gitlabds-2.2.0 → gitlabds-2.2.1}/PKG-INFO +4 -4
- {gitlabds-2.2.0 → gitlabds-2.2.1}/README.md +3 -3
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/record_benchmarking.py +13 -13
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds.egg-info/PKG-INFO +4 -4
- {gitlabds-2.2.0 → gitlabds-2.2.1}/LICENSE +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/__init__.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/baselines.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/config_generator.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/dummy.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/feature_descriptions.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/feature_reduction.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/insights.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/memory_optimization.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/missing.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/model_evaluator.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/monitoring_metrics.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/outliers.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/serving_features.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/split_data.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds/trends.py +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds.egg-info/SOURCES.txt +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds.egg-info/dependency_links.txt +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds.egg-info/requires.txt +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/gitlabds.egg-info/top_level.txt +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/pyproject.toml +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/setup.cfg +0 -0
- {gitlabds-2.2.0 → gitlabds-2.2.1}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlabds
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: GitLab Data Science Tools
|
|
5
5
|
Author-email: Kevin Dietz <kdietz@gitlab.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -836,13 +836,13 @@ Status label for a value vs. its peer median (+/- tolerance), not percentile ran
|
|
|
836
836
|
- _**labels**_ : tuple of (below average, average, above average, no activity) labels
|
|
837
837
|
|
|
838
838
|
#### Returns
|
|
839
|
-
- Series of
|
|
839
|
+
- Series of level labels, one per input value
|
|
840
840
|
|
|
841
841
|
#### Examples:
|
|
842
842
|
```python
|
|
843
843
|
import gitlabds
|
|
844
844
|
|
|
845
|
-
|
|
845
|
+
level = gitlabds.value_vs_peer_status(
|
|
846
846
|
value=df["monthly_spend"],
|
|
847
847
|
peer_median=df["peer_median_spend"],
|
|
848
848
|
peer_percentile=df["peer_percentile_spend"],
|
|
@@ -909,7 +909,7 @@ shap_df = gitlabds.per_record_shap(
|
|
|
909
909
|
- _**n_bins**_ : quantile bins for numeric `peer_group` columns
|
|
910
910
|
|
|
911
911
|
#### Returns
|
|
912
|
-
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `
|
|
912
|
+
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `level_before`, `level_after`, `crosses_band`
|
|
913
913
|
|
|
914
914
|
#### Requirements
|
|
915
915
|
For XGBoost models without `predict_proba`, requires the `xgboost` package (included in core dependencies).
|
|
@@ -804,13 +804,13 @@ Status label for a value vs. its peer median (+/- tolerance), not percentile ran
|
|
|
804
804
|
- _**labels**_ : tuple of (below average, average, above average, no activity) labels
|
|
805
805
|
|
|
806
806
|
#### Returns
|
|
807
|
-
- Series of
|
|
807
|
+
- Series of level labels, one per input value
|
|
808
808
|
|
|
809
809
|
#### Examples:
|
|
810
810
|
```python
|
|
811
811
|
import gitlabds
|
|
812
812
|
|
|
813
|
-
|
|
813
|
+
level = gitlabds.value_vs_peer_status(
|
|
814
814
|
value=df["monthly_spend"],
|
|
815
815
|
peer_median=df["peer_median_spend"],
|
|
816
816
|
peer_percentile=df["peer_percentile_spend"],
|
|
@@ -877,7 +877,7 @@ shap_df = gitlabds.per_record_shap(
|
|
|
877
877
|
- _**n_bins**_ : quantile bins for numeric `peer_group` columns
|
|
878
878
|
|
|
879
879
|
#### Returns
|
|
880
|
-
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `
|
|
880
|
+
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `level_before`, `level_after`, `crosses_band`
|
|
881
881
|
|
|
882
882
|
#### Requirements
|
|
883
883
|
For XGBoost models without `predict_proba`, requires the `xgboost` package (included in core dependencies).
|
|
@@ -5,7 +5,7 @@ These functions benchmark, explain, and prescribe changes for any indexed set of
|
|
|
5
5
|
scored records (accounts, users, deals, transactions, etc.) -- `unique_id` is just
|
|
6
6
|
whichever column identifies a row in your data. Includes:
|
|
7
7
|
|
|
8
|
-
- value_vs_peer_status :
|
|
8
|
+
- value_vs_peer_status : level label for a value vs. its peer median (+/- band)
|
|
9
9
|
- per_record_shap : per-record SHAP attribution (log-odds/margin space) for a tree model
|
|
10
10
|
- per_record_counterfactuals : per-record "change X -> +Y" counterfactual search
|
|
11
11
|
- per_record_peer_percentiles : per-record percentile standing within a peer group
|
|
@@ -43,7 +43,7 @@ def value_vs_peer_status(value, peer_median, good_direction=None, tolerance=0.15
|
|
|
43
43
|
labels : (below average, average, above average, no activity) labels to use
|
|
44
44
|
in place of the defaults.
|
|
45
45
|
|
|
46
|
-
Returns a Series of
|
|
46
|
+
Returns a Series of level labels, one per input value.
|
|
47
47
|
"""
|
|
48
48
|
value = pd.Series(value)
|
|
49
49
|
# index=value.index (not .reindex()) so a bare scalar broadcasts correctly.
|
|
@@ -56,9 +56,9 @@ def value_vs_peer_status(value, peer_median, good_direction=None, tolerance=0.15
|
|
|
56
56
|
with np.errstate(divide="ignore", invalid="ignore"):
|
|
57
57
|
rel_diff = (eff_value - eff_median) / denom
|
|
58
58
|
rel_diff = rel_diff.where(denom > 0, np.sign(eff_value - eff_median))
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
level = pd.Series(np.select([rel_diff > tolerance, rel_diff < -tolerance],
|
|
60
|
+
[labels[2], labels[0]], default=labels[1]),
|
|
61
|
+
index=value.index)
|
|
62
62
|
# "near ceiling": already above the peer median AND in the top ceiling_pct of the peer
|
|
63
63
|
# group toward good_direction. Gating on labels[2] (above average) means a compressed
|
|
64
64
|
# peer group whose top decile is still ~median is left "average", not falsely capped.
|
|
@@ -66,12 +66,12 @@ def value_vs_peer_status(value, peer_median, good_direction=None, tolerance=0.15
|
|
|
66
66
|
if peer_percentile is not None:
|
|
67
67
|
pct = pd.Series(peer_percentile, index=value.index).astype(float)
|
|
68
68
|
eff_pct = pct.where(~decreasing, 1 - pct) # percentile toward the good direction
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
level = level.mask((eff_pct >= ceiling_pct) & (level == labels[2]), ceiling_label)
|
|
70
|
+
level = level.mask(value.isna(), labels[3])
|
|
71
71
|
if no_activity_value is not None:
|
|
72
72
|
no_activity_value = pd.Series(no_activity_value, index=value.index)
|
|
73
|
-
|
|
74
|
-
return
|
|
73
|
+
level = level.where(value != no_activity_value, labels[3])
|
|
74
|
+
return level
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
def per_record_shap(
|
|
@@ -205,7 +205,7 @@ def per_record_counterfactuals(
|
|
|
205
205
|
|
|
206
206
|
Returns a long DataFrame: one row per (record, lever) with the best move found
|
|
207
207
|
(current_value, intervention_value, intervention_quantile, p_before/p_after/delta_p,
|
|
208
|
-
impact_bucket,
|
|
208
|
+
impact_bucket, level_before, level_after, crosses_band).
|
|
209
209
|
"""
|
|
210
210
|
if impact_medium >= impact_high:
|
|
211
211
|
raise ValueError(f"impact_medium ({impact_medium}) must be less than impact_high ({impact_high})")
|
|
@@ -289,9 +289,9 @@ def per_record_counterfactuals(
|
|
|
289
289
|
_labels = [label for label, _ in _sorted_bands]
|
|
290
290
|
def _band(p):
|
|
291
291
|
return pd.cut(p, bins=_edges, labels=_labels).astype(str)
|
|
292
|
-
out["
|
|
293
|
-
out["
|
|
294
|
-
out["
|
|
292
|
+
out["level_before"] = _band(out["p_before"])
|
|
293
|
+
out["level_after"] = _band(out["p_after"])
|
|
294
|
+
out["crosses_level"] = out["level_before"] != out["level_after"]
|
|
295
295
|
out.loc[out["crosses_band"] & (out["impact_bucket"] == "Low"), "impact_bucket"] = "Medium"
|
|
296
296
|
return out.sort_values([unique_id, "delta_p"], ascending=[True, False]).reset_index(drop=True)
|
|
297
297
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitlabds
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: GitLab Data Science Tools
|
|
5
5
|
Author-email: Kevin Dietz <kdietz@gitlab.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -836,13 +836,13 @@ Status label for a value vs. its peer median (+/- tolerance), not percentile ran
|
|
|
836
836
|
- _**labels**_ : tuple of (below average, average, above average, no activity) labels
|
|
837
837
|
|
|
838
838
|
#### Returns
|
|
839
|
-
- Series of
|
|
839
|
+
- Series of level labels, one per input value
|
|
840
840
|
|
|
841
841
|
#### Examples:
|
|
842
842
|
```python
|
|
843
843
|
import gitlabds
|
|
844
844
|
|
|
845
|
-
|
|
845
|
+
level = gitlabds.value_vs_peer_status(
|
|
846
846
|
value=df["monthly_spend"],
|
|
847
847
|
peer_median=df["peer_median_spend"],
|
|
848
848
|
peer_percentile=df["peer_percentile_spend"],
|
|
@@ -909,7 +909,7 @@ shap_df = gitlabds.per_record_shap(
|
|
|
909
909
|
- _**n_bins**_ : quantile bins for numeric `peer_group` columns
|
|
910
910
|
|
|
911
911
|
#### Returns
|
|
912
|
-
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `
|
|
912
|
+
- Long DataFrame, one row per (record, lever): `current_value`, `intervention_value`, `intervention_quantile`, `p_before`, `p_after`, `delta_p`, `impact_bucket`, `level_before`, `level_after`, `crosses_band`
|
|
913
913
|
|
|
914
914
|
#### Requirements
|
|
915
915
|
For XGBoost models without `predict_proba`, requires the `xgboost` package (included in core dependencies).
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|