Skip to main content

logo

Overview
Open Source BSD 3-clause
Code !pypi !python-versions
CI/CD !codecov
Downloads PyPI - Downloads PyPI - Downloads Downloads

Table of Contents
  1. About The Project
  2. Installation
  3. Testing
  4. Getting Started
  5. Contributing
  6. License

About The Project

Introduction

blocks is a package designed to extend the functionality of scikit-learn by providing additional blocks for creating custom pipelines, easy-to-use base transformers, and useful decorators. This package aims to simplify the process of building and managing machine learning workflows in Python.

The current version of the package offers:

  • Custom Pipelines: Easily create and manage custom pipelines
  • Base Transformers and Samplers: A collection of base transformers and samplers to streamline feature transformation
  • Decorators: Handy decorators to simplify repetitive tasks

(back to top)

Built With

  • scikit-learn = "^1.5.0"
  • imbalanced-learn = "^0.12.3"
  • pandas = "^2.2.2"
  • numpy = "^1.26.4"

(back to top)

Installation

The easiest way to install blocks is via PyPI:

pip install python-blocks

Or via poetry:

poetry add python-blocks

Testing

To run the test suite after installation, follow these steps from the source directory. First, install pytest version 8.2.2:

pip install pytest==8.2.2

Then run pytest as follow:

pytest tests

Alternatively, if you are using poetry, execute:

poetry run pytest

For more information, visit our Codecov page.

(back to top)

Getting Started

Pipeline

  • Callback function that logs information in between each intermediate step
  • Access particular named step data
  • Inherites from imblearn pipeline, which works with both transformers and samplers

Dataset

>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(n_samples=1000, n_features=10, random_state=42)

Model with both recorded and logged callbacks

>>> from sklearn.preprocessing import StandardScaler
>>> from sklearn.linear_model import LinearRegression
>>> from sklego.meta import EstimatorTransformer
>>> from blocks import BlockPipeline, custom_log_callback
>>> 
>>> pipe = BlockPipeline([
...   ("scaler", StandardScaler()),
...   ("regression", EstimatorTransformer(LinearRegression()))
... ],
...   record="scaler",
...   log_callback=custom_log_callback
... )

Logs

>>> pipe.fit(df, y)
# [custom_log_callback:78] - [scaler][StandardScaler()] shape=(1000, 10) time=0s

Records

>>> predicted = pipe.transform(df)
>>> pipe.name_record
# 'scaler'
>>> pipe.record
# array([[ ...

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

we also recommend to have a look at project-template.

project-template is a template project for scikit-learn compatible extensions. It aids development of estimators that can be used in scikit-learn pipelines and (hyper)parameter search, while facilitating testing (including some API compliance), documentation, open source development, packaging, and continuous integration.

Refer to the Official Documentation to modify the template for your own scikit-learn contribution.

(back to top)

License

Distributed under the BSD-3 License. See LICENSE.txt for more information.

(back to top)

Metadata

Release files for python-blocks 0.1.10

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

Source distribution (sdist)

Source distribution for python-blocks 0.1.10
File Size Uploaded
python_blocks-0.1.10.tar.gz 26.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-blocks 0.1.10
File Interpreter ABI Platform
python_blocks-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 52.9 kB

Release files / python_blocks-0.1.10.tar.gz

Download URL python_blocks-0.1.10.tar.gz
Size 26.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a9e3e598a70401c286c4e13bc78a5ddf5550b2ca798a99f706c7079d46f86946
BLAKE2b-256 checksum
How to use checksums
068eba992873d588ac4ca949c63767025a445c3909f6f5fa353413d0d881815d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/21.6.0

Release files / python_blocks-0.1.10-py3-none-any.whl

Download URL python_blocks-0.1.10-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c6ce8ff04c85bec8acc9e9ed0930ed0185de7c62a29d9a5e749bddde2e85207
BLAKE2b-256 checksum
How to use checksums
fadafcbbbde62b982314c1fe69f01ed9962cc400bb03989c4a375fa21b075bf2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.11.6 Darwin/21.6.0

Release history Release notifications | RSS feed

This release

0.1.10 This release

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

0.1.1

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