hyperopt conditional parameters DuplicateLabel exception

147 views
Skip to first unread message

Lynn Johnson

unread,
Aug 6, 2020, 3:46:56 PM8/6/20
to hyperopt-discuss
Hello -

I'm writing a hyperopt pipeline that performs various bioinformatics calculations, including aligning with the lastal program.  When I had un-conditional ranges, everything was fine. Now I"m trying to condition some parameters on others and apparently I'm not doing it correctly.  I'm trying to follow the user guide example of:

SPACE = hp.choice('classifier_type', [

    {

        'type': 'naive_bayes',

    },

    {

        'type': 'svm',

        'C': hp.lognormal('svm_C', 0, 1),

        'kernel': hp.choice('svm_kernel', [

            {'ktype': 'linear'},

            {'ktype': 'RBF', 'width': hp.lognormal('svm_rbf_width', 0, 1)},

            ]),

    },

    {

        'type': 'dtree',

        'criterion': hp.choice('dtree_criterion', ['gini', 'entropy']),

        'max_depth': hp.choice('dtree_max_depth',

            [None, hp.qlognormal('dtree_max_depth_int', 3, 1, 1)]),

        'min_samples_split': hp.qlognormal('dtree_min_samples_split', 2, 1, 1),

    },

    ])

I have 11 parameters whose values I want to shift, based on the value of one of them.  Specifically, -p is my matrix type for alignment.  Based on the -p value, I want to change some of the other parameter ranges.  Here is what I have coded which fails:

space = hp.choice('p_type',

  [

    {

      '-p': 'OFF',

      '-R' : hp.choice('-R',['10','11']),

      '-c' : hp.choice('-c',['OFF','ON']),

      '-U' : hp.choice('-U',['YASS','MAM8']),

      '-a' : hp.choice('-a',['7']),

      '-b' : hp.choice('-b',['1']),

      '-e' : hp.choice('-e',['30','40','50','60']),

      '-m' : hp.choice('-m',['50','100','150']),

      '-y' : hp.choice('-y',['9','10','15','20','25','30','35','40','45','50']),

      '-x' : hp.choice('-x',['20','30','40','50','60','70','80','90','100']),

      '-u' : hp.choice('-u',['1','2','3'])

    },

    {

      '-p': 'FILE',

      '-R' : hp.choice('-R',['10','11']),

      '-c' : hp.choice('-c',['ON']),

      '-U' : hp.choice('-U',['YASS','MAM8']),

      '-a' : hp.choice('-a',['16']),

      '-b' : hp.choice('-b',['1']),

      '-e' : hp.choice('-e',['60','80','100','120']),

      '-m' : hp.choice('-m',['50','100','150']),

      '-y' : hp.choice('-y',['15','20','25','30','35','40','45','50','55','60']),

      '-x' : hp.choice('-x',['30','40','50','60','70','80','90','100','110','120','130','140','150']),

      '-u' : hp.choice('-u',['1','2','3'])

    },

    {

      '-p': 'HOXD70',

      '-R' : hp.choice('-R',['10','11']),

      '-c' : hp.choice('-c',['ON']),

      '-U' : hp.choice('-U',['YASS','MAM8']),

      '-a' : hp.choice('-a',['400']),

      '-b' : hp.choice('-b',['30']),

      '-e' : hp.choice('-e',['3000','4000','5000']),

      '-m' : hp.choice('-m',['50','100','150']),

      '-y' : hp.choice('-y',['1000','1200','1400','1600','1800','2000']),

      '-x' : hp.choice('-x',['1500','1750','2000','2250','2500']),

      '-u' : hp.choice('-u',['1','2','3'])

    },


  ])

The error is :

Traceback (most recent call last):

  File "msa_align_hyperopt_containerName_ArminAug2.py", line 265, in <module>

    best=fmin(fmin_objective, space, algo=tpe.rand.suggest, max_evals=3)

  File "/home/lcj34/miniconda3/lib/python3.7/site-packages/hyperopt/fmin.py", line 492, in fmin

    domain = base.Domain(fn, space, pass_expr_memo_ctrl=pass_expr_memo_ctrl)

  File "/home/lcj34/miniconda3/lib/python3.7/site-packages/hyperopt/base.py", line 829, in __init__

    raise DuplicateLabel(label)

hyperopt.exceptions.DuplicateLabel: -R

How should I be coding this so that the list of parameters depend on the value of -p, which can be 'OFF','FILE' or 'HOXD70'.

Thanks



Lynn Johnson

unread,
Aug 6, 2020, 6:01:11 PM8/6/20
to hyperopt-discuss
I've gotten this to work by changing the space to this:

space = hp.choice('p_type',

  [

    {

      '-p': 'OFF',

      '-R' : hp.choice('-R-1',['10','11']),

      '-c' : hp.choice('-c-1',['OFF','ON']),

      '-U' : hp.choice('-U-1',['YASS','MAM8']),

      '-a' : hp.choice('-a-1',['7']),

      '-b' : hp.choice('-b-1',['1']),

      '-e' : hp.choice('-e-1',['30','40','50','60']),

      '-m' : hp.choice('-m-1',['50','100','150']),

      '-y' : hp.choice('-y-1',['9','10','15','20','25','30','35','40','45','50']),

      '-x' : hp.choice('-x-1',['20','30','40','50','60','70','80','90','100']),

      '-u' : hp.choice('-u-1',['1','2','3'])

    },

    {

      '-p': 'FILE',

      '-R' : hp.choice('-R-2',['10','11']),

      '-c' : hp.choice('-c-2',['ON']),

      '-U' : hp.choice('-U-2',['YASS','MAM8']),

      '-a' : hp.choice('-a-2',['16']),

      '-b' : hp.choice('-b-2',['1']),

      '-e' : hp.choice('-e-2',['60','80','100','120']),

      '-m' : hp.choice('-m-2',['50','100','150']),

      '-y' : hp.choice('-y-2',['15','20','25','30','35','40','45','50','55','60']),

      '-x' : hp.choice('-x-2',['30','40','50','60','70','80','90','100','110','120','130','140','150']),

      '-u' : hp.choice('-u-2',['1','2','3'])

    },

    {

      '-p': 'HOXD70',

      '-R' : hp.choice('-R-3',['10','11']),

      '-c' : hp.choice('-c-3',['ON']),

      '-U' : hp.choice('-U-3',['YASS','MAM8']),

      '-a' : hp.choice('-a-3',['400']),

      '-b' : hp.choice('-b-3',['30']),

      '-e' : hp.choice('-e-3',['3000','4000','5000']),

      '-m' : hp.choice('-m-3',['50','100','150']),

      '-y' : hp.choice('-y-3',['1000','1200','1400','1600','1800','2000']),

      '-x' : hp.choice('-x-3',['1500','1750','2000','2250','2500']),

      '-u' : hp.choice('-u-3',['1','2','3'])

    },


  ])



Is this the most efficient way to define these conditional parameters?  Note that in some cases, they are the same across the p_type.

--
You received this message because you are subscribed to a topic in the Google Groups "hyperopt-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hyperopt-discuss/May258CQHQY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hyperopt-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hyperopt-discuss/a2a83390-971e-40a6-8d13-f08a3bc1c19bo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages