コード例 #1
0
ファイル: BruteForce.py プロジェクト: modaresimr/UnifiedAR
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
コード例 #2
0
    {'method': lambda: metric.classical.Accuracy()},
    #{'method': lambda: Accuracy()},
]

methods.event_metric = [
    # {'method': lambda: metric.Accuracy.Accuracy()},
    #{'method': lambda: Accuracy()},
]

methods.activity_fetcher = [
    {'method': lambda: activity_fetcher.MaxActivityFetcher.MaxActivityFetcher()},
    # {'method': lambda: activity_fetcher.CookActivityFetcher.CookActivityFetcher()}
    ]
methods.combiner = [
    {'method':lambda: combiner.SimpleCombiner.EmptyCombiner2()},
    # {'method':lambda: combiner.SimpleCombiner.SimpleCombiner()},
    # {'method':lambda: combiner.SimpleCombiner.EmptyCombiner()},
    ]
methods.evaluation = [
     {'method': lambda: evaluation.KFoldEval.KFoldEval(5)},
     {'method': lambda: evaluation.KFoldEval.PKFoldEval(5)},
     {'method': lambda: evaluation.SimpleEval.SimpleEval()},
]


methods.feature_extraction = [
    {'method': lambda:feature_extraction.KHistory.KHistory(), 'params':[{'k':2},{'method':feature_extraction.Simple.Simple()}],'findopt':False},
    {'method': lambda:feature_extraction.KHistory.KHistory(), 'params':[{'k':1},{'method':feature_extraction.Cook.Cook1()}],'findopt':False},
    {'method': lambda:feature_extraction.KHistory.KHistory(), 'params':[{'k':1},{'method':feature_extraction.Simple.Simple()}],'findopt':False},
    {'method': lambda:feature_extraction.Simple.Simple(), 'params':[], 'findopt':False},
     {'method': lambda:feature_extraction.DeepLearningFeatureExtraction.DeepLearningFeatureExtraction(), 'params':[