اين charts

bar chart distribution
والباقى



cell 17
in original notebook

probs, true_labels, test_indices = predict_probabilities(model, test_loader)

thresholds = [0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50, 0.60, 0.70, 0.80, 0.90]
rows = []

for th in thresholds:
    preds = (probs >= th).astype(int)
    metrics = evaluate_binary(true_labels, preds)
    metrics.update({
        "model": "LogMiniLM",
        "window_method": "fixed_10_line",
        "threshold": th,
        "window_size": WINDOW_SIZE,
        "step_size": STEP_SIZE,
        "projection_dim": PROJECTION_DIM,
        "transformer_layers": NUM_TRANSFORMER_LAYERS,
        "attention_heads": NUM_ATTENTION_HEADS,
        "feedforward_dim": FEEDFORWARD_DIM,
        "train_sequences": len(y_train),
        "test_sequences": len(y_test),
        "unique_messages": len(unique_texts),
    })
    rows.append(metrics)

results_df = pd.DataFrame(rows).sort_values("f1", ascending=False).reset_index(drop=True)
results_df.to_csv(RESULTS_PATH, index=False)

print("Saved results to:", RESULTS_PATH)
display(results_df)

best_row = results_df.iloc[0]
best_threshold = float(best_row["threshold"])
print("\nBest threshold:", best_threshold)
print("Best F1-score:", best_row["f1"])
print("Best accuracy:", best_row["accuracy"])
 يراجعى مؤاجعه الجزء ده