def get_evaluator(params, base): pprint(params) L = list() if params['missingSeparate'] == True: L.append("-M") if params['locallyPredictive'] == False: L.append("-L") if params['search'] == 'GreedyStepwise': param_search = gs.get_params() search = gs.get_search(param_search) else: param_search = bf.get_params() search = bf.get_search(param_search) # search = ASSearch(classname="weka.attributeSelection."+params['search']) evaluator = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval", options=L) clf = Classifier( classname="weka.classifiers.meta.AttributeSelectedClassifier") clf.set_property("evaluator", evaluator.jobject) clf.set_property("search", search.jobject) clf.set_property("base", base.jobject) return clf
def try_params(n_instances, params, base, train, valid, test, istest): n_instances = int(round(n_instances)) pprint(params) L = list() if params['missingSeparate'] == True: L.append("-M") if params['locallyPredictive'] == False: L.append("-L") if params['search'] == 'GreedyStepwise': param_search = gs.get_params() search = gs.get_class(param_search) else: param_search = bf.get_params() search = bf.get_class(param_search) # search = ASSearch(classname="weka.attributeSelection."+params['search']) evaluator = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval", options=L) clf = Classifier( classname="weka.classifiers.meta.AttributeSelectedClassifier") clf.set_property("evaluator", evaluator.jobject) clf.set_property("base", base.jobject) if istest: result = test_weka_classifier(clf, train, test) else: result = train_and_eval_weka_classifier(clf, train, valid, n_instances) return result
def try_params(n_instances, params, base, train, valid, test, istest): n_instances = int(round(n_instances)) pprint(params) L = list() if params['missing_merge'] == True: L.append("-M") if params['search'] == 'GreedyStepwise': param_search = gs.get_params() search = gs.get_search(param_search) elif params['search'] == 'BestFirst': param_search = bf.get_params() search = bf.get_search(param_search) elif params['search'] == 'Ranker': param_search = rk.get_params() search = rk.get_search(param_search) # search = ASSearch(classname="weka.attributeSelection."+params['search']) evaluator = ASEvaluation(classname="weka.attributeSelection.GainRatioAttributeEval", options=L) clf = Classifier(classname="weka.classifiers.meta.AttributeSelectedClassifier") clf.set_property("evaluator", evaluator.jobject) clf.set_property("search", search.jobject) clf.set_property("base", base.jobject) if istest: result = test_weka_classifier(clf, train, test) else: result = train_and_eval_weka_classifier(clf, train, valid, n_instances) return result
def get_evaluator(params, base): pprint(params) L = list() L.append("-E") L.append(str(params['ev_measure'])) L.append("-R") L.append(str(params['seed'])) L.append("-T") L.append(str(params['threshold'])) if params['search'] == 'GreedyStepwise': param_search = gs.get_params() search = gs.get_search(param_search) elif params['search'] == 'BestFirst': param_search = bf.get_params() search = bf.get_search(param_search) elif params['search'] == 'Ranker': param_search = rk.get_params() search = rk.get_search(param_search) # search = ASSearch(classname="weka.attributeSelection."+params['search']) evaluator = ASEvaluation( classname="weka.attributeSelection.WrapperSubsetEval", options=L) clf = Classifier( classname="weka.classifiers.meta.AttributeSelectedClassifier") clf.set_property("evaluator", evaluator.jobject) clf.set_property("search", search.jobject) clf.set_property("base", base.jobject) return clf