def method_param_selector(callback, uniquekey): import itertools from constants import methods s = [ methods.preprocessing, methods.segmentation, methods.activity_fetcher, methods.feature_extraction, methods.classifier ] permut = list(itertools.product(*s)) allpool = [] for item in permut: func = Data('Functions') func.uniquekey = uniquekey func.preprocessor = createFunction(item[0]) func.segmentor = createFunction(item[1]) func.activityFetcher = createFunction(item[2]) func.featureExtractor = createFunction(item[3]) func.classifier = createFunction(item[4]) func.combiner = createFunction(methods.combiner[0]) func.classifier_metric = createFunction(methods.classifier_metric[0]) func.event_metric = createFunction(methods.classifier_metric[0]) func.shortrunname = '' for k in func.__dict__: obj = func.__dict__[k] if isinstance(obj, MyTask): obj.func = func func.shortrunname += obj.shortname() + '_' optl = OptLearn(func, callback) allpool.append(optl) # break success, fail = run(allpool, True) bestJobscore = success[0].result['optq']['q'] bestJob = success[0] for job in success: if (bestJobscore > job.result['optq']['q']): bestJobscore = job.result['optq']['q'] bestJob = job return bestJob
methods.classifier = [ {'method': lambda: classifier.Keras.LSTMTest(), 'params': [ {'epochs': 10} ]}, {'method': lambda:classifier.libsvm.LibSVM()}, {'method': lambda: classifier.Keras.SimpleKeras(), 'params': [ {'epochs': 3} ]}, # {'method': lambda: classifier.PyActLearn.PAL_LSTM_Legacy(), 'params': [ # {'var': 'epochs', 'init': 3} # ]}, {'method': lambda: classifier.MySKLearn.UAR_RandomForest(), 'params': [ {'n_estimators': 20}, {'random_state':0} ]}, {'method': lambda: classifier.MySKLearn.UAR_KNN(), 'params': [ {'k': 5}, ]}, {'method': lambda: classifier.MySKLearn.UAR_SVM(), 'params': [ {'kernel':'rbf'}, { 'gamma': 1}, { 'C': 100.}, {'decision_function_shape':'ovr'} ]}, {'method': lambda: classifier.MySKLearn.UAR_SVM2(), 'params': [ {'kernel': 'linear'}, {'gamma': 1}, {'C':100.}, {'decision_function_shape':'ovr'} ]}, {'method': lambda: classifier.MySKLearn.UAR_DecisionTree(), 'params': [ ]}, ]