Skip to main content

Bender 🤖

A Python package for faster, safer, and simpler ML processes.

Why use bender?

Bender will make your machine learning processes, faster, safer, simpler while at the same time making it easy and flexible. This is done by providing a set base component, around the core processes that will take place in a ML pipeline process. While also helping you with type hints about what your next move could be.

Pipeline Safety

The whole pipeline is build using generics from Python's typing system. Resulting in an improved developer experience, as the compiler can know if your pipeline's logic makes sense before it has started.

Bender will therefore make sure you can't make errors like

# ⛔️ Invalid pipeline
DataImporters.sql(...)
    .process([...])
    # Compile Error: method `predict()` is not available
    .predict()

# ✅ Valid pipeline
DataImporters.sql(...)
    .process([...])
    .load_model(ModelLoader.aws_s3(...))
    .predict()

Training Example

Below is a simple example for training a XGBoosted tree

DataImporters
    # Fetch SQL data
    .sql(sql_url, sql_query)

    # Preproces the data
    .process([
        # Extract advanced information from json data
        Transformations.unpack_json("purchases", key="price", output_feature="price", policy=UnpackPolicy.median_number())

        Transformations.log_normal_shift("y_values", "y_log"),

        # Get date values from a date feature
        Transformations.date_component("month", "date", output_feature="month_value"),
    ])

    # Split 70 / 30% for train and test set
    .split(SplitStrategies.ratio(0.7))

    # Train a XGBoosted Tree model
    .train(
        ModelTrainer.xgboost(),
        input_features=['y_log', 'price', 'month_value', 'country', ...],
        target_feature='did_buy_product_x'
    )

    # Evaluate how good the model is based on the test set
    .evaluate([
        Evaluators.roc_curve(),
        Evaluators.confusion_matrix(),
        Evaluators.precision_recall(
            # Overwrite where to export the evaluated result
            Exporter.disk("precision-recall.png")
        ),
    ])

Predicting Example

Below will a model be loaded from a AWS S3 bucket, preprocess the data, and predict the output. This will also make sure that the features are valid before predicting.

ModelLoaders
    # Fetch Model
    .aws_s3("path/to/model", s3_config)

    # Load data
    .import_data(
        DataImporters.sql(sql_url, sql_query)
            # Caching import localy for 1 day
            .cached("cache/path")
    )
    # Preproces the data
    .process([
        Transformations.unpack_json(...),
        ...
    ])
    # Predict the values
    .predict()

Release files for benderml 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for benderml 0.1.1
File Size Uploaded
benderml-0.1.1.tar.gz 24.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for benderml 0.1.1
File Interpreter ABI Platform
benderml-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size:61.8 kB

Release files / benderml-0.1.1.tar.gz

Download URL benderml-0.1.1.tar.gz
Size 24.2 kB
Tags Source
SHA-256 checksum
How to use checksums
df764569cff41b0e19d40ffcc358ea044979330f79583a3d8c2874075a7840b8
BLAKE2b-256 checksum
How to use checksums
03c0d325cef9bc17dada3dd907e1ad869c3bb7b50d4813f3b544a138b28a39a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure

Release files / benderml-0.1.1-py3-none-any.whl

Download URL benderml-0.1.1-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42323a988712a5daf43e81ab912fce0983ecc4af16e5b65e18f490aef4b1b59f
BLAKE2b-256 checksum
How to use checksums
c9a32cef61da199a75be3186d68029e1a39a2323e8226484227421ad2cb91b06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.9.9 Linux/5.11.0-1022-azure

Release history Release notifications | RSS feed

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page