Commit ad56a5bc authored by burcharr's avatar burcharr 💬
Browse files

save progress on code and notebooks

parent 0be202d7
This diff is collapsed.
This diff is collapsed.
......@@ -39,14 +39,32 @@ def f1_score_multi(y_true, y_pred, by_class=False):
return np.mean(f1_res)
def s_score_multi(y_true, y_pred, by_class=False):
f1_res = []
for cls in np.unique(y_true):
y_true_copy = y_true.copy()
y_pred_copy = y_pred.copy()
y_true_copy[y_true_copy != cls] = -1
y_true_copy[y_true_copy == cls] = 1
y_true_copy[y_true_copy == -1] = 0
y_pred_copy[y_pred_copy != cls] = -1
y_pred_copy[y_pred_copy == cls] = 1
y_pred_copy[y_pred_copy == -1] = 0
f1 = S1_score(y_true_copy, y_pred_copy)
f1_res.append(f1)
if by_class:
return f1_res
return np.mean(f1_res)
def run_all_scores(y_true, y_pred):
return specificity(y_true, y_pred), sensitivity(y_true, y_pred), f1_score(y_true, y_pred), S1_score(y_true, y_pred)
def plot_confusion_matrix(y_true, y_pred, labels=None, normalize="true", ax=None):
cm = confusion_matrix(y_true, y_pred, labels=labels, normalize=normalize)
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=labels,)
disp = ConfusionMatrixDisplay(confusion_matrix=cm, display_labels=labels)
disp.plot(ax=ax)
disp.ax_.get_images()[0].set_clim(0, .9) # set the value range
return disp
return disp, np.mean(np.diagonal(cm))
......@@ -179,7 +179,7 @@ def evaluate_with_convolutions(models, X_test, y_test, kernel_width=None, fixed_
pt = True
res = []
for kernel_width in [10, 15, 20, 25,30,35,40,45] if kernel_width is None else [kernel_width]:
for kernel_width in [10, 15, 20, 25, 30, 35, 40, 45] if kernel_width is None else [kernel_width]:
best_comb = -2
global_best = -2
for i, model_name in enumerate(models):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment