import numpy as np def sigmoid(z): return 1 / (1 + np.exp(-z)) def logistic_regression_predict(x, w, b): z = w * x + b return sigmoid(z) distances = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], dtype=float) late = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1], dtype=float) w, b = 2, -11 probabilities = logistic_regression_predict(distances, w, b) for d, p, actual in zip(distances, probabilities, late): print(f"{d:.0f} km -> P(late) = {p:.4f} (actually {'late' if actual else 'not late'})") __ __