Base class for pipeline

As far as I understood in order to create a custom c3 pipeline with python we need to implement two methods: ‘fit’ and ‘transform’. As an example:

    class MyClass(object):
    def __init__(self):
       # do nothing
    def fit(self):
       # do nothing
    def transform(self):
      # do something

Is it possible to import a common interface to avoid boilerplate coding? Here an example

    from c3Library import BaseEstimator
    class MyClass(BaseEstimator):
    def transform(self):
       # do something

Yes, you could create a class if you end up creating a lot of estimators that share the same code.
On order to reuse Python code today, you can define a type MyMixinType.c3typ and your base estimator class or some functions in MyMixinType.py.
Any type that mixes MyMixinType will see those Python class/functions available.

Thank you for the reply.

Does the platform has this feature already available by default in some python package? (I don’t want to reinvent the wheel :slightly_smiling_face:)

Hey There,

Yes there are several such types. You should be able to check these by running:
c3ShowType(MLLeafPipe) and checking the “used by” section. This can also be accessed by api: MetadataStore.tag().typesThatMixin(MLLeafPipe).

Examples include:
SklearnPipe, TensorflowPipe and XgBoostPipe

To build your own, make sure to check the documentation on ActionRuntime for information on integrating a new python library.

Thank you for your help, I will look at the documentation.

I believe your question was slightly different: no, we do not provide a BaseEstimator python class in a package (mostly because the implementation of MLLeafPipe is extremely generic at this point so a BaseEstimator would be pretty basic and would not save us much code, if any).