gitlabds 2.4.3__tar.gz → 2.4.5__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.
Files changed (34) hide show
  1. {gitlabds-2.4.3 → gitlabds-2.4.5}/PKG-INFO +22 -10
  2. {gitlabds-2.4.3 → gitlabds-2.4.5}/README.md +21 -9
  3. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/insights.py +14 -2
  4. gitlabds-2.4.5/gitlabds/serving_features.py +510 -0
  5. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds.egg-info/PKG-INFO +22 -10
  6. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds.egg-info/SOURCES.txt +1 -0
  7. gitlabds-2.4.5/tests/test_serving_features.py +178 -0
  8. gitlabds-2.4.3/gitlabds/serving_features.py +0 -430
  9. {gitlabds-2.4.3 → gitlabds-2.4.5}/LICENSE +0 -0
  10. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/__init__.py +0 -0
  11. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/baselines.py +0 -0
  12. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/config_generator.py +0 -0
  13. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/dummy.py +0 -0
  14. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/feature_descriptions.py +0 -0
  15. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/feature_reduction.py +0 -0
  16. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/memory_optimization.py +0 -0
  17. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/missing.py +0 -0
  18. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/model_evaluator.py +0 -0
  19. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/monitoring_metrics.py +0 -0
  20. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/outliers.py +0 -0
  21. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/record_benchmarking.py +0 -0
  22. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/snowflake_connectors.py +0 -0
  23. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/split_data.py +0 -0
  24. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds/trends.py +0 -0
  25. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds.egg-info/dependency_links.txt +0 -0
  26. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds.egg-info/requires.txt +0 -0
  27. {gitlabds-2.4.3 → gitlabds-2.4.5}/gitlabds.egg-info/top_level.txt +0 -0
  28. {gitlabds-2.4.3 → gitlabds-2.4.5}/pyproject.toml +0 -0
  29. {gitlabds-2.4.3 → gitlabds-2.4.5}/setup.cfg +0 -0
  30. {gitlabds-2.4.3 → gitlabds-2.4.5}/setup.py +0 -0
  31. {gitlabds-2.4.3 → gitlabds-2.4.5}/tests/test_feature_reduction.py +0 -0
  32. {gitlabds-2.4.3 → gitlabds-2.4.5}/tests/test_record_benchmarking.py +0 -0
  33. {gitlabds-2.4.3 → gitlabds-2.4.5}/tests/test_snowflake_connectors.py +0 -0
  34. {gitlabds-2.4.3 → gitlabds-2.4.5}/tests/test_split_data.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitlabds
3
- Version: 2.4.3
3
+ Version: 2.4.5
4
4
  Summary: GitLab Data Science Tools
5
5
  Author-email: Kevin Dietz <kdietz@gitlab.com>
6
6
  License-Expression: MIT
@@ -790,7 +790,13 @@ display(effects_df)
790
790
  ```
791
791
  </details>
792
792
 
793
- <details><summary> Prescriptions </summary>
793
+ <details><summary> Prescriptions (deprecated) </summary>
794
+
795
+ > **Deprecated:** `prescriptions` raises a `DeprecationWarning` and will be removed in a future
796
+ > release. Use `per_record_shap` and `per_record_counterfactuals` instead. Note that
797
+ > `per_record_shap` requires a tree-based model (e.g. LightGBM, XGBoost), so they are not a
798
+ > drop-in replacement for linear/logistic models. They also choose each move's direction from
799
+ > the model and size moves from peer-group quantiles rather than a fixed step.
794
800
 
795
801
  #### Description
796
802
  Return "actionable" prescriptions and explanatory insights for each scored record. Insights first list actionable prescriptions follow by explainatory insights. This approach is recommended or linear/logistic methodologies only. Caution should be used if using a black box approach, as manpulating more than one prescription at a time could change a record's model score in unintended ways.
@@ -1391,24 +1397,30 @@ Also worth knowing:
1391
1397
  <details><summary> Serve Features </summary>
1392
1398
 
1393
1399
  #### Description
1394
- Serve features from Snowflake Feature Store with built-in distributed locking and retry logic. This function orchestrates feature retrieval from multiple feature views with support for point-in-time lookups and flexible parameter customization.
1400
+ Serve features from Snowflake Feature Store with per-call UDF parameters and retry logic. Each call shadows the shared `{FV}_DYNAMIC` view with a `CREATE OR REPLACE TEMPORARY VIEW` of the same name, so the parameters apply only to your Snowpark session: callers on other sessions (including your own other notebooks) never see them, and the permanent view keeps its UDF defaults.
1401
+
1402
+ - **Schema:** view and UDF names are qualified with the feature view's database and schema, so a `USE SCHEMA` in your session doesn't change what is served.
1403
+ - **Redeploying in the same session:** the temporary views last until the session closes, so a session that serves and then redeploys the permanent `_DYNAMIC` view keeps reading its temporary view until the next `serve_features` call. Use a fresh session to read the redeployed defaults.
1404
+ - **Concurrency:** calls sharing one session object run one at a time. Open one session per thread for real parallelism.
1405
+ - **Feature-date check:** when `feature_date` is set, the served date is checked and a mismatch raises a warning, not an error: some feature views use a timestamp other than the snapshot date (e.g. a refresh week), so a mismatch isn't always wrong. With `spine_timestamp_col` and `include_feature_view_timestamp_col=True` the returned `{FV}_{version}_FEATURE_DATE` column is checked; otherwise the session's temporary view is queried before retrieval, which may run the whole UDF.
1406
+ - **Spine timestamps earlier than `feature_date`** match no feature rows in the point-in-time join and return all-null features. A warning is raised when this happens.
1395
1407
 
1396
- `gitlabds.serve_features(session, feature_store, feature_views_dict, spine_df=None, feature_date=None, spine_timestamp_col=None, include_feature_view_timestamp_col=False, lookback_window_value=None, lookback_window_unit=None, lock_timeout_seconds=300, max_fetch_retries=3, fetch_retry_backoff_seconds=30):`
1408
+ `gitlabds.serve_features(session, feature_store, feature_views_dict, spine_df=None, feature_date=None, spine_timestamp_col=None, include_feature_view_timestamp_col=False, lookback_window_value=None, lookback_window_unit=None, lock_timeout_seconds=None, max_fetch_retries=3, fetch_retry_backoff_seconds=30):`
1397
1409
 
1398
1410
  #### Parameters:
1399
- - **_session_** : Active Snowflake Session object
1411
+ - **_session_** : Active Snowflake Session object. Must be the session the FeatureStore was built with (`feature_store._session`); a different session raises `ValueError`, because retrieval could not see this call's temporary views.
1400
1412
  - **_feature_store_** : Initialized FeatureStore instance
1401
1413
  - **_feature_views_dict_** : Dictionary mapping feature view names to versions (e.g., {"sales_activities": "1.0"})
1402
1414
  - **_spine_df_** : One of the following:
1403
1415
  - SQL query string to generate the spine DataFrame
1404
1416
  - pandas DataFrame (will be converted to Snowpark DataFrame)
1405
1417
  - Snowpark DataFrame (used directly)
1406
- - **_feature_date_** : Date for feature retrieval (e.g., '2025-04-08'). If None, uses UDF default.
1418
+ - **_feature_date_** : Date for feature retrieval (e.g., '2025-04-08'). If None, uses UDF default and skips the feature-date check.
1407
1419
  - **_spine_timestamp_col_** : Name of timestamp column in spine DataFrame for point-in-time lookup. Used for when multiple feature_dates may be present in the feature view. If only one feature_date is present, can set value to None for faster execution.
1408
- - **_include_feature_view_timestamp_col_** : Whether to include timestamp column from feature views in output. Default is False.
1420
+ - **_include_feature_view_timestamp_col_** : Whether to include timestamp column from feature views in output. Only takes effect with `spine_timestamp_col`. Default is False.
1409
1421
  - **_lookback_window_value_** : Either a global integer value (e.g., 6) or a dict with feature-view-specific values
1410
1422
  - **_lookback_window_unit_** : Either a global string value (e.g., 'months') or a dict with feature-view-specific values
1411
- - **_lock_timeout_seconds_** : Timeout in seconds for acquiring the Snowflake lock. Default is 300.
1423
+ - **_lock_timeout_seconds_** : Deprecated and ignored; the Snowflake lock table is no longer used. Passing it raises a `DeprecationWarning`.
1412
1424
  - **_max_fetch_retries_** : Maximum number of attempts for the result-fetch step (`retrieve_feature_values` + `to_arrow().to_pandas()`) when a transient network/streaming error occurs (e.g., `ChunkedEncodingError`, "Response ended prematurely"). Set to 1 to disable retries. Default is 3.
1413
1425
  - **_fetch_retry_backoff_seconds_** : Base sleep duration between fetch retries. Sleep grows linearly with attempt number (`attempt * backoff`). With defaults (3 retries, 30s base), sleeps are 30s before attempt 2 and 60s before attempt 3. Default is 30.
1414
1426
 
@@ -1468,10 +1480,10 @@ features = gitlabds.serve_features(
1468
1480
 
1469
1481
  </details>
1470
1482
 
1471
- <details><summary> Clear Feature Serving Locks </summary>
1483
+ <details><summary> Clear Feature Serving Locks (deprecated) </summary>
1472
1484
 
1473
1485
  #### Description
1474
- Utility function to manually clear all feature serving locks. Use this if locks get stuck due to killed processes.
1486
+ **Deprecated.** `serve_features` no longer uses the `FEATURE_SERVING_LOCKS` table, so there is nothing to get stuck. This clears any leftover rows from that table, raises a `DeprecationWarning`, and will be removed in a future release. The table can be dropped.
1475
1487
 
1476
1488
  `gitlabds.clear_feature_serving_locks(session):`
1477
1489
 
@@ -754,7 +754,13 @@ display(effects_df)
754
754
  ```
755
755
  </details>
756
756
 
757
- <details><summary> Prescriptions </summary>
757
+ <details><summary> Prescriptions (deprecated) </summary>
758
+
759
+ > **Deprecated:** `prescriptions` raises a `DeprecationWarning` and will be removed in a future
760
+ > release. Use `per_record_shap` and `per_record_counterfactuals` instead. Note that
761
+ > `per_record_shap` requires a tree-based model (e.g. LightGBM, XGBoost), so they are not a
762
+ > drop-in replacement for linear/logistic models. They also choose each move's direction from
763
+ > the model and size moves from peer-group quantiles rather than a fixed step.
758
764
 
759
765
  #### Description
760
766
  Return "actionable" prescriptions and explanatory insights for each scored record. Insights first list actionable prescriptions follow by explainatory insights. This approach is recommended or linear/logistic methodologies only. Caution should be used if using a black box approach, as manpulating more than one prescription at a time could change a record's model score in unintended ways.
@@ -1355,24 +1361,30 @@ Also worth knowing:
1355
1361
  <details><summary> Serve Features </summary>
1356
1362
 
1357
1363
  #### Description
1358
- Serve features from Snowflake Feature Store with built-in distributed locking and retry logic. This function orchestrates feature retrieval from multiple feature views with support for point-in-time lookups and flexible parameter customization.
1364
+ Serve features from Snowflake Feature Store with per-call UDF parameters and retry logic. Each call shadows the shared `{FV}_DYNAMIC` view with a `CREATE OR REPLACE TEMPORARY VIEW` of the same name, so the parameters apply only to your Snowpark session: callers on other sessions (including your own other notebooks) never see them, and the permanent view keeps its UDF defaults.
1365
+
1366
+ - **Schema:** view and UDF names are qualified with the feature view's database and schema, so a `USE SCHEMA` in your session doesn't change what is served.
1367
+ - **Redeploying in the same session:** the temporary views last until the session closes, so a session that serves and then redeploys the permanent `_DYNAMIC` view keeps reading its temporary view until the next `serve_features` call. Use a fresh session to read the redeployed defaults.
1368
+ - **Concurrency:** calls sharing one session object run one at a time. Open one session per thread for real parallelism.
1369
+ - **Feature-date check:** when `feature_date` is set, the served date is checked and a mismatch raises a warning, not an error: some feature views use a timestamp other than the snapshot date (e.g. a refresh week), so a mismatch isn't always wrong. With `spine_timestamp_col` and `include_feature_view_timestamp_col=True` the returned `{FV}_{version}_FEATURE_DATE` column is checked; otherwise the session's temporary view is queried before retrieval, which may run the whole UDF.
1370
+ - **Spine timestamps earlier than `feature_date`** match no feature rows in the point-in-time join and return all-null features. A warning is raised when this happens.
1359
1371
 
1360
- `gitlabds.serve_features(session, feature_store, feature_views_dict, spine_df=None, feature_date=None, spine_timestamp_col=None, include_feature_view_timestamp_col=False, lookback_window_value=None, lookback_window_unit=None, lock_timeout_seconds=300, max_fetch_retries=3, fetch_retry_backoff_seconds=30):`
1372
+ `gitlabds.serve_features(session, feature_store, feature_views_dict, spine_df=None, feature_date=None, spine_timestamp_col=None, include_feature_view_timestamp_col=False, lookback_window_value=None, lookback_window_unit=None, lock_timeout_seconds=None, max_fetch_retries=3, fetch_retry_backoff_seconds=30):`
1361
1373
 
1362
1374
  #### Parameters:
1363
- - **_session_** : Active Snowflake Session object
1375
+ - **_session_** : Active Snowflake Session object. Must be the session the FeatureStore was built with (`feature_store._session`); a different session raises `ValueError`, because retrieval could not see this call's temporary views.
1364
1376
  - **_feature_store_** : Initialized FeatureStore instance
1365
1377
  - **_feature_views_dict_** : Dictionary mapping feature view names to versions (e.g., {"sales_activities": "1.0"})
1366
1378
  - **_spine_df_** : One of the following:
1367
1379
  - SQL query string to generate the spine DataFrame
1368
1380
  - pandas DataFrame (will be converted to Snowpark DataFrame)
1369
1381
  - Snowpark DataFrame (used directly)
1370
- - **_feature_date_** : Date for feature retrieval (e.g., '2025-04-08'). If None, uses UDF default.
1382
+ - **_feature_date_** : Date for feature retrieval (e.g., '2025-04-08'). If None, uses UDF default and skips the feature-date check.
1371
1383
  - **_spine_timestamp_col_** : Name of timestamp column in spine DataFrame for point-in-time lookup. Used for when multiple feature_dates may be present in the feature view. If only one feature_date is present, can set value to None for faster execution.
1372
- - **_include_feature_view_timestamp_col_** : Whether to include timestamp column from feature views in output. Default is False.
1384
+ - **_include_feature_view_timestamp_col_** : Whether to include timestamp column from feature views in output. Only takes effect with `spine_timestamp_col`. Default is False.
1373
1385
  - **_lookback_window_value_** : Either a global integer value (e.g., 6) or a dict with feature-view-specific values
1374
1386
  - **_lookback_window_unit_** : Either a global string value (e.g., 'months') or a dict with feature-view-specific values
1375
- - **_lock_timeout_seconds_** : Timeout in seconds for acquiring the Snowflake lock. Default is 300.
1387
+ - **_lock_timeout_seconds_** : Deprecated and ignored; the Snowflake lock table is no longer used. Passing it raises a `DeprecationWarning`.
1376
1388
  - **_max_fetch_retries_** : Maximum number of attempts for the result-fetch step (`retrieve_feature_values` + `to_arrow().to_pandas()`) when a transient network/streaming error occurs (e.g., `ChunkedEncodingError`, "Response ended prematurely"). Set to 1 to disable retries. Default is 3.
1377
1389
  - **_fetch_retry_backoff_seconds_** : Base sleep duration between fetch retries. Sleep grows linearly with attempt number (`attempt * backoff`). With defaults (3 retries, 30s base), sleeps are 30s before attempt 2 and 60s before attempt 3. Default is 30.
1378
1390
 
@@ -1432,10 +1444,10 @@ features = gitlabds.serve_features(
1432
1444
 
1433
1445
  </details>
1434
1446
 
1435
- <details><summary> Clear Feature Serving Locks </summary>
1447
+ <details><summary> Clear Feature Serving Locks (deprecated) </summary>
1436
1448
 
1437
1449
  #### Description
1438
- Utility function to manually clear all feature serving locks. Use this if locks get stuck due to killed processes.
1450
+ **Deprecated.** `serve_features` no longer uses the `FEATURE_SERVING_LOCKS` table, so there is nothing to get stuck. This clears any leftover rows from that table, raises a `DeprecationWarning`, and will be removed in a future release. The table can be dropped.
1439
1451
 
1440
1452
  `gitlabds.clear_feature_serving_locks(session):`
1441
1453
 
@@ -1,3 +1,5 @@
1
+ import warnings
2
+
1
3
  import pandas as pd
2
4
  import numpy as np
3
5
 
@@ -283,8 +285,18 @@ def prescriptions(model, input_df:pd.DataFrame, scored_df:pd.DataFrame, actionab
283
285
  explanation_fields : List of explainable (non-actionable insights) fields to return insights for. Defaults to 'all' for all fields.
284
286
 
285
287
 
286
- Returns a Dataframe of prescriptive actions. One row per record input."""
287
-
288
+ Returns a Dataframe of prescriptive actions. One row per record input.
289
+
290
+ Deprecated: use per_record_shap and per_record_counterfactuals instead. prescriptions will
291
+ be removed in a future release."""
292
+
293
+ warnings.warn(
294
+ "gitlabds.prescriptions is deprecated and will be removed in a future release. "
295
+ "Use gitlabds.per_record_shap and gitlabds.per_record_counterfactuals instead.",
296
+ DeprecationWarning,
297
+ stacklevel=2,
298
+ )
299
+
288
300
  bf = pd.DataFrame(input_df.columns.tolist(), columns=['feature'])
289
301
 
290
302
  change_score = pd.DataFrame()