PHOTON is an object-oriented python framework for optimizing machine learning pipelines. It is designed to leave you deciding the important things and automatizing the rest.

PHOTON gives you an easy way of setting up a full stack machine learning pipeline including nested cross-validation and hyperparameter search.

After PHOTON has found the best configuration for your model, it offers a convenient possibility to explore the analyzed hyperparameter space. It also enables you to persist and load your optimal model, including all preprocessing steps, with only one line of code.

PHOTON Architecture


You only need two things: Python 3 and your favourite Python IDE to get started. Then simply install PHOTON via pip.

        pip install photonai

Getting Started

        my_pipe = Hyperpipe('basic_svm_pipe_no_performance',
                    metrics=['accuracy', 'precision', 'recall'],

        my_pipe += PipelineElement('StandardScaler')

        my_pipe += PipelineElement('PCA', hyperparameters={'n_components': [5, 10, None]}, test_disabled=True)

        my_pipe += PipelineElement('SVC', hyperparameters={'kernel': Categorical(['rbf', 'linear']),
                                                           'C': FloatRange(0.5, 2, "linspace", num=5)}), y)

Setup and optimize your machine learning pipeline in 5 lines of code.

We are using a very basic pipeline here:

We repeat the hyperparameter search three times using a KFold split for the outer cross-validation loop, and we test each configuration ten times with a KFold split on the inner cross-validation loop.

Hyperparameter search is done with our good old friend grid search. For each configuration, we are interested in the accuracy, recall and precision of the learning model. After all configurations have been tested, we pick the optimum configuration by maximizing the metric accuracy.

Our pipeline has two preprocessing steps: We add a standard scaler for normalization and a PCA for feature space reduction. For both of them we specify some hyperparameters we want to test. Finally, we add a support vector machine for classification, again specifying some options for the hyperparameters.

With, targets) you start the hyperparameter search including the nested cross validation, so that you end up having PHOTON delivering you the best configured model for your data as well as its generalized performance.

Easy Customizing

PHOTON is based on simple interfaces, so you can add any custom code in just to no time.

  • add custom preprocessing elements
  • add custom models
  • any element is automatically enabled and integrated in the hyperparameter search

Seamless Integration

Choose elements from a big pool of diverse toolboxes

  • add any scikit-learn algorithms
  • add keras or tensorflow models