def test_tmva(): # check classifier check_classifier(TMVAClassifier(), check_instance=True, has_staged_pp=False, has_importances=False) cl = TMVAClassifier(method='kSVM', Gamma=0.25, Tol=0.001, sigmoid_function='identity') check_classifier(cl, check_instance=True, has_staged_pp=False, has_importances=False) cl = TMVAClassifier(method='kCuts', FitMethod='GA', EffMethod='EffSel', sigmoid_function='sig_eff=0.9') check_classifier(cl, check_instance=True, has_staged_pp=False, has_importances=False) # check regressor, need to run twice to check for memory leak. for i in range(2): check_regression(TMVARegressor(), check_instance=True, has_staged_predictions=False, has_importances=False)
def test_complex_stacking_tmva(): # Ada over kFold over TMVA base_kfold = FoldingClassifier(base_estimator=TMVAClassifier(), random_state=13) check_classifier(SklearnClassifier( clf=AdaBoostClassifier(base_estimator=base_kfold, n_estimators=3)), has_staged_pp=False, has_importances=False)
def test_tmva(): # check classifier factory_options = "Silent=True:V=False:DrawProgressBar=False" cl = TMVAClassifier(factory_options=factory_options, method='kBDT', NTrees=10) check_classifier(cl, check_instance=True, has_staged_pp=False, has_importances=False) cl = TMVAClassifier(factory_options=factory_options, method='kSVM', Gamma=0.25, Tol=0.001, sigmoid_function='identity') check_classifier(cl, check_instance=True, has_staged_pp=False, has_importances=False) cl = TMVAClassifier(factory_options=factory_options, method='kCuts', FitMethod='GA', EffMethod='EffSel', sigmoid_function='sig_eff=0.9') check_classifier(cl, check_instance=True, has_staged_pp=False, has_importances=False) # check regressor, need to run twice to check for memory leak. for i in range(2): check_regression(TMVARegressor(factory_options=factory_options, method='kBDT', NTrees=10), check_instance=True, has_staged_predictions=False, has_importances=False)
def grid_tmva(score_function): grid_param = OrderedDict({"MaxDepth": [4, 5], "NTrees": [10, 20]}) generator = SubgridParameterOptimizer(grid_param) scorer = FoldingScorer(score_function) from rep.estimators import TMVAClassifier grid = GridOptimalSearchCV(TMVAClassifier(features=['column0', 'column1']), generator, scorer) cl = check_grid(grid, False, False, False) assert 1 <= len(cl.features) <= 3 params = cl.get_params() for key in grid_param: assert params[key] == grid.generator.best_params_[key]
def test_gridsearch_on_tmva(): metric = numpy.random.choice([OptimalAMS(), RocAuc()]) scorer = FoldingScorer(metric) grid_param = OrderedDict({"MaxDepth": [4, 5], "NTrees": [10, 20]}) generator = SubgridParameterOptimizer(grid_param) try: from rep.estimators import TMVAClassifier grid = GridOptimalSearchCV( TMVAClassifier(features=['column0', 'column1']), generator, scorer) classifier = check_grid(grid, False, False, False) # checking parameters assert len(classifier.features) == 2 params = classifier.get_params() for key in grid_param: assert params[key] == grid.generator.best_params_[key] except ImportError: pass
def test_gridsearch_on_tmva(): metric = numpy.random.choice([OptimalAMS(), RocAuc()]) scorer = FoldingScorer(metric) grid_param = OrderedDict({"MaxDepth": [4, 5], "NTrees": [10, 20]}) generator = SubgridParameterOptimizer(n_evaluations=5, param_grid=grid_param) try: from rep.estimators import TMVAClassifier base_tmva = TMVAClassifier( factory_options="Silent=True:V=False:DrawProgressBar=False", features=['column0', 'column1'], method='kBDT') grid = GridOptimalSearchCV(base_tmva, generator, scorer) classifier = check_grid(grid, False, False, False) # checking parameters assert len(classifier.features) == 2 params = classifier.get_params() for key in grid_param: assert params[key] == grid.generator.best_params_[key] except ImportError: pass
def test_simple_stacking_tmva(): base_tmva = TMVAClassifier() check_classifier(SklearnClassifier(clf=BaggingClassifier( base_estimator=base_tmva, n_estimators=3, random_state=13)), has_staged_pp=False, has_importances=False)
def test_complex_stacking_tmva(): # Ada over kFold over TMVA base_kfold = FoldingClassifier(base_estimator=TMVAClassifier(factory_options="Silent=True:V=False:DrawProgressBar=False", method='kBDT', NTrees=10), random_state=13) check_classifier(SklearnClassifier(clf=AdaBoostClassifier(base_estimator=base_kfold, n_estimators=3)), has_staged_pp=False, has_importances=False)
def test_simple_stacking_tmva(): base_tmva = TMVAClassifier(factory_options="Silent=True:V=False:DrawProgressBar=False") check_classifier(SklearnClassifier(clf=BaggingClassifier(base_estimator=base_tmva, n_estimators=3, random_state=13)), has_staged_pp=False, has_importances=False)