From dcdf1a23fbfdc18a0ce5385c2d6df2be9556628f Mon Sep 17 00:00:00 2001 From: Joshua Wendland Date: Fri, 10 Nov 2023 10:11:05 +0100 Subject: [PATCH] small bug fixes --- Makefile | 4 ++++ plotsandgraphs/binary_classifier.py | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index e0641ae..b541671 100644 --- a/Makefile +++ b/Makefile @@ -32,9 +32,13 @@ fmt: ## Format code using black & isort. .PHONY: lint lint: ## Run pep8, black, mypy linters. + @echo "Running linters ..." + @echo "--- Running flake8 ---" $(ENV_PREFIX)flake8 plotsandgraphs/ + @echo "--- Running black ---" $(ENV_PREFIX)black -l 79 --check plotsandgraphs/ $(ENV_PREFIX)black -l 79 --check tests/ + @echo "--- Running mypy ---" $(ENV_PREFIX)mypy --ignore-missing-imports plotsandgraphs/ .PHONY: test diff --git a/plotsandgraphs/binary_classifier.py b/plotsandgraphs/binary_classifier.py index e6fd62f..3c69486 100644 --- a/plotsandgraphs/binary_classifier.py +++ b/plotsandgraphs/binary_classifier.py @@ -35,7 +35,7 @@ def plot_accuracy(y_true, y_pred, name='', save_fig_path=None) -> Figure: path = Path(save_fig_path) path.parent.mkdir(parents=True, exist_ok=True) fig.savefig(save_fig_path, bbox_inches='tight') - return fig, accuracy + return fig def plot_confusion_matrix(y_true: np.ndarray, y_pred: np.ndarray, save_fig_path=None) -> Figure: import matplotlib.colors as colors @@ -136,7 +136,7 @@ def plot_classification_report(y_test: np.ndarray, mask[:,cols-1] = True bounds = np.linspace(0, 1, 11) - cmap = plt.cm.get_cmap('YlOrRd', len(bounds)+1) + cmap = plt.cm.get_cmap('YlOrRd', len(bounds)+1) # type: ignore norm = colors.BoundaryNorm(bounds, cmap.N) # type: ignore[attr-defined] ax = sns.heatmap(df, mask=mask, annot=False, cmap=cmap, fmt='.3g', @@ -428,8 +428,8 @@ def plot_pr_curve( # Plot Precision-Recall curve ax.plot(recall, precision, label=label, color=color) - ax.set_xlim([0.0, 1.01]) - ax.set_ylim([-0.01, 1.01]) + ax.set_xlim((0.0, 1.01)) + ax.set_ylim((-0.01, 1.01)) ax.set_xlabel('Recall') ax.set_ylabel('Precision') if title is not None: