Skip to main content

Leakage-safe, point-in-time feature engineering for event logs.

Project description

safefeat

Leakage-safe, point-in-time feature engineering for event logs.

safefeat builds features for each (entity_id, cutoff_time) using only events that occurred at or before the cutoff time (no future data leakage).

Install

pip install safefeat

Example

from safefeat import build_features, WindowAgg

spec = [
    WindowAgg(
        table="events",
        windows=["7D", "30D"],
        metrics={
            "*": ["count"],              # total events
            "amount": ["sum", "mean"],   # numeric aggregations
            "event_type": ["nunique"],   # categorical unique counts
        },
    )
]

X = build_features(
    spine=spine,
    tables={"events": events},
    spec=spec,
    event_time_cols={"events": "event_time"},
    allowed_lag="0s",  # prevent future leakage
)

print(X)

Expected output :

| entity_id | cutoff_time | events__n_events__7d | events__amount__sum__30d |
| --------- | ----------- | -------------------- | ------------------------ |
| u1        | 2024-01-10  | 2                    | 30                       |
| u2        | 2024-01-10  | 1                    | 5                        |

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safefeat-0.1.0.tar.gz (619.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safefeat-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file safefeat-0.1.0.tar.gz.

File metadata

  • Download URL: safefeat-0.1.0.tar.gz
  • Upload date:
  • Size: 619.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for safefeat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1085f90abeae7bba1b23ddcb6c997c12d6d539cf2b369eac525148009f72f7ce
MD5 4a913e6464d1908b0f6d8aa99aef863f
BLAKE2b-256 e05c53e2bffedd0781266376fb1f5eb92163b142cbea8e01591e545dcbfdc006

See more details on using hashes here.

File details

Details for the file safefeat-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: safefeat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for safefeat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8c8e7efd6d9b48aec39adce17af6e9770ecdc5140057893daeaed0356a5790b6
MD5 9f4f4404f27ddc5e7d0e71c5f1832550
BLAKE2b-256 2bd7178a2f584468c1b208c0c95cd1836dfaf161dcbac96a538da19ccf60bab9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page