PHOTONAI Register

The PHOTONAI Register class lets you register your class with a key, so that you can access it conveniently in your PHOTONAI Hyperpipe setup via the PipelineElement class.
           
import os
from photonai.base import Hyperpipe, PipelineElement,PhotonRegistry


# REGISTER ELEMENT
base_folder = os.path.dirname(os.path.abspath(__file__))
custom_elements_folder = os.path.join(base_folder, 'custom_elements')

registry = PhotonRegistry(custom_elements_folder=custom_elements_folder)

# This needs to be done only once on your device
registry.register(photon_name='MyCustomEstimator',
                  class_str='custom_estimator.CustomEstimator',
                  element_type='Estimator')

registry.register(photon_name='MyCustomTransformer',
                  class_str='custom_transformer.CustomTransformer',
                  element_type='Transformer')

# This needs to be done every time you run the script
registry.activate()

# SHOW WHAT IS POSSIBLE IN THE CONSOLE
registry.list_available_elements()

# NOW FIND OUT MORE ABOUT A SPECIFIC ELEMENT
registry.info('MyCustomEstimator')
registry.info('MyCustomTransformer')


# DESIGN YOUR PIPELINE
my_pipe = Hyperpipe(...)

my_pipe += PipelineElement('MyCustomEstimator')

my_pipe.fit(X, y)