pythonpython-3.xscikit-learntpot

Configuring njobs with Python tpot


Can the njobs parameter be configured using tpot within code and not passed as command line parameter ?

Reading https://rhiever.github.io/tpot/using/ states :

-njobs  NUM_JOBS    Any positive integer or -1  Number of CPUs for evaluating pipelines in parallel during the TPOT optimization process. 

Assigning this to -1 will use as many cores as available on the computer.

But how to configure this parameter within code ?

Trying :

TPOTClassifier(generations=5, verbosity=3,  config_dict='TPOT light' , NUM_JOBS = 4)  

returns error :

TPOTClassifier(generations=5, verbosity=3,  config_dict='TPOT light' , NUM_JOBS = 4)
TypeError: __init__() got an unexpected keyword argument 'NUM_JOBS'

Solution

  • Achieved using n_jobs parameter:

    TPOTClassifier(
        generations=5,
        verbosity=3,
        config_dict='TPOT light',
        n_jobs=4
    )