Skip to main content

Simple pipeline alternative to Scikit Learn's Pipeline.

Project description

What is Paip? And Why Paip?

"Paip" is a Malay word of "pipe", a lightweight library that is alternative to Scikit Learn pipeline.

In general, Scikit Learn's pipeline facilitates the chaining of transformers in series and execute them in sequential order. Then, the pipeline can be serialized and re-used easily at different environment. However, the existing Scikit Learn's pipeline only allows objects to be loaded into the step list. If there is a small piece of code that is needed in between transformers (e.g. change of column name of data frame), we need to revise the small piece of code into object-oriented paradigm in order to obtain the corresponding objects. Need less to say, the class definition has to be imported at the new environment during the unpicke process.

To overcome this issue, we have developed a lightweight library named Paip that allows both runtime code and transformers to be executed in the pipelines.

For example, we have a data frame, X that needs to go through two feature transformations, i.e. transformer1 and transformer2. In between the transformers, we need to rename the column, "x1" to "x1_new". The code is presented in the following.

from paipline import Paip

# Somewhere here, we have created the data frame, `X`.
# Somewhere here, we have created feature transformation, named `transformer1`.
# Somewhere here, we have created feature transformation, named `transformer2`.

step_list = []

# Add the transformer 1 into the step list.
step_list.append(
    {'name': 'Transformer 1', # name
     'obj_dict' : {'transformer1': transformer1}, # The objects to be serialized in pickle.
      'run_dict':{
                'transform': ['X = transformer1.transform(X)'], # Run this code.
            },
     'output_list' : ['X', ] # Whitelist these variables will go to next step.
    }
)

# Add the transformer 2 into the step list.
step_list.append(
    {'name': 'Transformer 1',
     'obj_dict' : {'transformer1': transformer1},
      'run_dict':{
                'transform': [
                    'X = X.rename(columns={"x1": "x1_new")',  # Rename column.
                    'X = transformer1.transform(X)'
                ],
            },
     'output_list' : ['X', ]
    }
)


paip1 = Paip(step_list)

paip1.run('transform', # run those command that tag with "transform"
          {'X': X,},    # the variable to bring into the pipeline.
          debug = True)   # Debug output 

# Retrieve the output
X_out = paip1.output_dict['X']

And to serialize Paip, we use the existing joblib.

import joblib
joblib('./test.paip', paip1)

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

paipline-zkchong-0.0.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

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

paipline_zkchong-0.0.1-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file paipline-zkchong-0.0.1.tar.gz.

File metadata

  • Download URL: paipline-zkchong-0.0.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for paipline-zkchong-0.0.1.tar.gz
Algorithm Hash digest
SHA256 65a1fca58f293cd742048fef02e69efe4a90043c451de0a12d1f996a951e47f3
MD5 8b47812265bc4c68989dbd0dee9fdbf4
BLAKE2b-256 f8121c484258450920fc8267393f33e9ea6479c103ef57935ec41d97499cbc5f

See more details on using hashes here.

File details

Details for the file paipline_zkchong-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: paipline_zkchong-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for paipline_zkchong-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6faa1009d989cbb7383d9e20f4cf1d066f3ba69ca04dcd1fe18b3bb616f39d50
MD5 3be9cf40eba3b1567c3e475f32e49456
BLAKE2b-256 fb3b8cb7eb74ac07133c8a1f35c0be2ff22539236d0fe906b066978149edaa40

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