def domain_adaptation_plot_helper(classifiers, metric='acc'): print "Plotting domain_adaptation, classifiers: %s" % classifiers METHODS = ['target_only', 'source_only', 'relabeled', 'augment', 'coral'] dfs = [] for method in METHODS: for classifier in classifiers: df = get_da_results(classifier, method, metric) util.print_ci_from_df(df['folds'], method, classifier) dfs.append(df) dfs = pd.concat(dfs) if metric == 'acc': y_label = "Accuracy" elif metric == 'fms': y_label = "F-Measure" else: y_label = "AUC" plot_specs = { 'x_col': 'method', 'y_col': 'folds', 'hue_col': 'model', 'x_label': 'Model', 'figsize': (10, 8), 'font_scale': 1.2, 'fontsize': 20, 'y_label': y_label, 'y_lim': (0, 1) } figname = 'domain_adapt_plot_%s_%s.pdf' % (metric, classifiers[1]) bar_plot(dfs, figname, **plot_specs)
def vanilla_feature_set_plot(show=False): print "Plotting vanilla_feature_set_plot" dfs = [] classifiers = models.CLASSIFIER_KEYS for classifier in classifiers: for metric in models.METRICS: df = get_vanilla_results(classifier, metric) util.print_ci_from_df(df['folds'], classifier, metric) dfs.append(df) dfs = pd.concat(dfs) plot_specs = { 'x_col': 'model', 'y_col': 'folds', 'hue_col': 'metric', 'x_label': 'Model', 'y_label': 'Performance', 'figsize': (12, 10), 'font_scale': 1.2, 'fontsize': 20, 'y_lim': None, 'show': show, 'title': "10-Fold Cross Validation Performance" } figname = 'vanilla_results.pdf' bar_plot(dfs, figname, **plot_specs)
def blog_plot(): print "Plotting blog_plot" metrics = models.METRICS dfs = [] for classifier in models.CLASSIFIER_KEYS: for metric in metrics: df = get_blog_results(classifier, metric) util.print_ci_from_df(df['folds'], classifier, metric) dfs.append(df) dfs = pd.concat(dfs) plot_specs = { 'x_col': 'model', 'y_col': 'folds', 'hue_col': 'metric', 'x_label': 'Model', 'y_label': 'Performance', 'font_scale': 1.2, 'fontsize': 20, 'rotation': 15 } figname = 'blog_plot.pdf' bar_plot(dfs, figname, **plot_specs)
def selected_feature_set_result(metric, feature_sets): name, _ = feature_sets print "Getting results of %s, metric: %s" % (name, metric) classifiers = list(models.CLASSIFIER_KEYS) for fs in ['none']: for classifier in classifiers: df = get_selected_feature_results(classifier, metric, name) util.print_ci_from_df(df['folds'], fs, classifier)
def print_fraser_comparision(metric='fms'): print 'metric %s' % metric t0 = 'results_new_features_fraser_comparision_none' t1 = 'results_new_features_fraser_comparision_halves' t2 = 'results_new_features_poly_halves' t3 = 'results_new_features_none' df0 = util.get_max_fold_from_table(metric, t0) df1 = util.get_max_fold_from_table(metric, t1) df2 = util.get_max_fold_from_table(metric, t2) df3 = util.get_max_fold_from_table(metric, t3) util.print_ci_from_df(df0['folds'], "without_age_without_halves", "LogReg") util.print_ci_from_df(df1['folds'], "without_age_with_halves", "LogReg") util.print_ci_from_df(df2['folds'], "with_age_with_halves", "LogReg") util.print_ci_from_df(df3['folds'], "with_age_without_halves", "LogReg")
def blog_ablation_plot(metric='acc'): print "Plotting blog_ablation_plot, metric: %s" % metric classifiers = models.CLASSIFIER_KEYS ablation_sets = models.BLOG_FEATURE_SETS classifiers.remove('DummyClassifier') dfs = [] for classifier in classifiers: for ab_set in ablation_sets: df = get_ablation_results(ab_set, classifier, metric, BLOG_ABLATION_PREFIX) util.print_ci_from_df(df['folds'], classifier, metric) dfs.append(df) dfs = pd.concat(dfs) human_readable = {"acc": "Accuracy", "fms": "F-Measure", "roc": "AUC"} plot_specs = { 'x_col': 'ablation_set', 'y_col': 'folds', 'hue_col': 'model', 'x_label': 'Feature Set', 'y_label': "Change in %s " % human_readable[metric], 'title': "Feature Ablation", 'figsize': (10, 8), 'fontsize': 20, 'font_scale': 1.2, 'y_lim': None, 'errwidth': 0.75, 'labelsize': 10, 'rotation': 15 } figname = 'blog_ablation_plot.pdf' bar_plot(dfs, figname, **plot_specs)
def new_feature_set_plot(metric='acc', absolute=True, poly=True, show=False): print "Plotting new_feature_set_plot, metric: %s" % metric classifiers = list(models.CLASSIFIER_KEYS) new_features = [] if absolute: new_features += ['none'] new_features += models.NEW_FEATURE_SETS classifiers.remove('DummyClassifier') dfs = [] for fs in new_features: for classifier in classifiers: df = get_new_feature_results(fs, classifier, metric, absolute=absolute, poly=poly) util.print_ci_from_df(df['folds'], fs, classifier) dfs.append(df) dfs = pd.concat(dfs) dfs = dfs.replace('none', 'baseline') y_lim = (.68, .90) if metric == 'acc': y_label = "Accuracy" elif metric == 'fms': y_label = "F-Measure" else: y_label = "AUC" y_lim = (.70, .95) figname = 'new_feature_plot_%s' % metric title = 'Performance w/ New Feature Sets' if not absolute: y_label = "Change in %s" % y_label y_lim = (-.10, .10) figname = figname + '_relative' title = 'Change in Performance w/ New Feature Sets' plot_specs = { 'x_col': 'new_feature_set', 'y_col': 'folds', 'hue_col': 'model', 'x_label': 'Feature Set', 'y_label': y_label, 'y_lim': y_lim, 'figsize': (10, 8), 'fontsize': 20, 'font_scale': 1.2, 'labelsize': 15, 'show': show, 'title': title, } # We use polynomial terms as well for halves if poly: dfs = dfs.replace('halves', 'halves+quadratic') else: figname = figname + '_without_quadratic' figname = figname + '.pdf' bar_plot(dfs, figname, **plot_specs)