else: filtered_learner = Orange.feature.selection.FilteredLearner( learner, filter=Orange.feature.selection.FilterBestN(n=filter), name='filtered') classifier = filtered_learner(data) return classifier if __name__ == "__main__": if len(sys.argv) != 4: print >> sys.stderr, "Usage: classify.py [TAB_FILE] [classifier: tree, bayes, svm, logreg] [number to filter, 0 -> no filtering]" sys.exit(1) data = proj_utils.load_data(sys.argv[1]) type = sys.argv[2] features = int(sys.argv[3]) train_data, test_data = proj_utils.partition_data(data) model = train_classifier(train_data, type, features) train_CA, train_results = proj_utils.test_classifier(model, train_data) test_CA, test_results = proj_utils.test_classifier(model, test_data) #print "Train Accuracy: %f, Test Accuracy: %f" % (train_CA, test_CA) train_stats = proj_utils.get_stats(train_results) test_stats = proj_utils.get_stats(test_results) print "Train:\n%s" % str(train_stats) print "\nTest:\n%s" % str(test_stats)
exit() if filter == 0: classifier = learner(data) else: filtered_learner = Orange.feature.selection.FilteredLearner(learner, filter=Orange.feature.selection.FilterBestN(n=filter), name='filtered') classifier = filtered_learner(data) return classifier if __name__ == "__main__": if len(sys.argv) != 4: print >> sys.stderr, "Usage: classify.py [TAB_FILE] [classifier: tree, bayes, svm, logreg] [number to filter, 0 -> no filtering]" sys.exit(1) data = proj_utils.load_data(sys.argv[1]) type = sys.argv[2] features = int(sys.argv[3]) train_data, test_data = proj_utils.partition_data(data) model = train_classifier(train_data, type, features) train_CA, train_results = proj_utils.test_classifier(model, train_data) test_CA, test_results = proj_utils.test_classifier(model, test_data) #print "Train Accuracy: %f, Test Accuracy: %f" % (train_CA, test_CA) train_stats = proj_utils.get_stats(train_results) test_stats = proj_utils.get_stats(test_results) print "Train:\n%s" % str(train_stats) print "\nTest:\n%s" % str(test_stats)