Extra blocks for scikit-learn features.
Project description
Table of Contents
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
Built With
scikit-learn = "^1.5.0"
imbalanced-learn = "^0.12.3"
pandas = "^2.2.2"
numpy = "^1.26.4"
Installation
To get started with blocks
, you can clone the repository to your local machine. Ensure you have Git installed, then run the following command:
$ git clone https://github.com/ActurialCapital/blocks.git
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([[ ...
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
we also recommend to have a look at project-template
.
project-template
is a template project forscikit-learn
compatible extensions. It aids development of estimators that can be used inscikit-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.
License
Distributed under the BSD-3 License. See LICENSE.txt
for more information.
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
Built Distribution
Hashes for python_blocks-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a8e8bc24564aa20530c2c23b74fd54d152f8b3cc011ec4eaeb45093ee4e6799 |
|
MD5 | 0ea3f1c54b245d4d65684c453d38376f |
|
BLAKE2b-256 | 8903aef14ee8b64288d0b437f1651c4d48868004ffcd922e0346aa6f63cff239 |