import%20marimo%0A%0A__generated_with%20%3D%20%220.24.0%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Note%2002%3A%20Norms%20and%20Metrics%3A%20Measuring%20Size%20and%20Distance%0A%0A%20%20%20%20%26larr%3B%20Previous%20Note%3A%20%5B01%20Inner%20Products%5D(01_inner_product.py)%20%7C%20Next%20Note%3A%20%5B03%20Hyperplanes%5D(03_hyperplanes.py)%20%26rarr%3B%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Ba%5D%20Why%20do%20you%20need%20to%20know%20these%20concepts%3F%0A%0A%20%20%20%20Machine%20learning%20is%20fundamentally%20about%20**minimizing%20distances**%20between%20predictions%20and%20targets%2C%20**constraining%20the%20size**%20of%20model%20parameters%2C%20and%20**measuring%20separation**%20between%20data%20points.%20Every%20one%20of%20these%20operations%20relies%20on%20a%20norm%20or%20a%20metric%3A%0A%0A%20%20%20%20-%20**Loss%20functions**%3A%20MSE%20computes%20the%20squared%20%24L_2%24%20norm%20of%20the%20residual%20vector%20%24%5C%7C%5Cmathbf%7By%7D%20-%20%5Chat%7B%5Cmathbf%7By%7D%7D%5C%7C_2%5E2%24.%20MAE%20uses%20the%20%24L_1%24%20norm.%0A%20%20%20%20-%20**Regularization**%3A%20Ridge%20uses%20the%20%24L_2%24%20norm%20of%20weights%20(%24%5C%7C%5Cmathbf%7Bw%7D%5C%7C_2%5E2%24).%20Lasso%20uses%20%24L_1%24%20(%24%5C%7C%5Cmathbf%7Bw%7D%5C%7C_1%24).%20The%20choice%20of%20norm%20determines%20whether%20weights%20are%20shrunk%20uniformly%20or%20driven%20to%20exact%20zero%20(sparsity).%0A%20%20%20%20-%20**Nearest-neighbor%20algorithms**%3A%20KNN%2C%20DBSCAN%2C%20and%20retrieval%20systems%20all%20require%20a%20distance%20metric%20to%20define%20%22closeness.%22%0A%20%20%20%20-%20**Gradient%20clipping**%3A%20Training%20deep%20networks%20often%20clips%20%24%5C%7C%5Cnabla%5C%7C_2%24%20to%20prevent%20exploding%20gradients.%0A%20%20%20%20-%20**Batch%20normalization**%3A%20Normalizes%20activations%20by%20their%20%24L_2%24%20statistics%20across%20the%20batch.%0A%0A%20%20%20%20**Prerequisites**%3A%20Chapter%201%20(vectors)%2C%20Chapter%202%20(inner%20products%2C%20from%20which%20norms%20are%20derived).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bb%5D%20Concept%20explanation%20with%20their%20role%20in%20ML%2FAI%2FStats%3F%0A%0A%20%20%20%20%23%23%23%20Norm%3A%20Measuring%20the%20%22Size%22%20of%20a%20Vector%0A%0A%20%20%20%20A%20**norm**%20is%20a%20function%20%24%5C%7C%5Ccdot%5C%7C%20%3A%20V%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D%24%20satisfying%20three%20axioms%3A%0A%0A%20%20%20%20%7C%20Axiom%20%7C%20Formula%20%7C%20Intuition%20%7C%0A%20%20%20%20%7C%20%3A---%20%7C%20%3A---%20%7C%20%3A---%20%7C%0A%20%20%20%20%7C%20**Non-negativity**%20%7C%20%24%5C%7C%5Cmathbf%7Bv%7D%5C%7C%20%5Cgeq%200%24%3B%20%24%5C%7C%5Cmathbf%7Bv%7D%5C%7C%20%3D%200%20%5Ciff%20%5Cmathbf%7Bv%7D%20%3D%20%5Cmathbf%7B0%7D%24%20%7C%20Only%20the%20zero%20vector%20has%20zero%20size%20%7C%0A%20%20%20%20%7C%20**Absolute%20scalability**%20%7C%20%24%5C%7C%5Calpha%20%5Cmathbf%7Bv%7D%5C%7C%20%3D%20%7C%5Calpha%7C%20%5C%7C%5Cmathbf%7Bv%7D%5C%7C%24%20%7C%20Scaling%20a%20vector%20scales%20its%20length%20%7C%0A%20%20%20%20%7C%20**Triangle%20inequality**%20%7C%20%24%5C%7C%5Cmathbf%7Bu%7D%20%2B%20%5Cmathbf%7Bv%7D%5C%7C%20%5Cleq%20%5C%7C%5Cmathbf%7Bu%7D%5C%7C%20%2B%20%5C%7C%5Cmathbf%7Bv%7D%5C%7C%24%20%7C%20The%20%22shortcut%22%20is%20never%20longer%20than%20going%20around%20%7C%0A%0A%20%20%20%20%23%23%23%20The%20%24L_p%24%20Norm%20Family%0A%0A%20%20%20%20For%20%24%5Cmathbf%7Bx%7D%20%5Cin%20%5Cmathbb%7BR%7D%5En%24%20and%20%24p%20%5Cgeq%201%24%3A%0A%20%20%20%20%24%24%0A%20%20%20%20%5C%7C%5Cmathbf%7Bx%7D%5C%7C_p%20%3D%20%5Cleft(%5Csum_%7Bi%3D1%7D%5En%20%7Cx_i%7C%5Ep%5Cright)%5E%7B1%2Fp%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20%7C%20Norm%20%7C%20%24p%24%20%7C%20Unit%20%22Circle%22%20Shape%20%7C%20ML%20Usage%20%7C%0A%20%20%20%20%7C%20%3A---%20%7C%20%3A---%3A%20%7C%20%3A---%20%7C%20%3A---%20%7C%0A%20%20%20%20%7C%20%24L_1%24%20(Manhattan)%20%7C%201%20%7C%20Diamond%20%7C%20Lasso%20(%24L_1%24%20penalty)%2C%20sparsity%2C%20MAE%20loss%20%7C%0A%20%20%20%20%7C%20%24L_2%24%20(Euclidean)%20%7C%202%20%7C%20Circle%20%7C%20Ridge%20(%24L_2%24%20penalty)%2C%20MSE%20loss%2C%20cosine%20similarity%20%7C%0A%20%20%20%20%7C%20%24L_%5Cinfty%24%20(Chebyshev)%20%7C%20%24%5Cinfty%24%20%7C%20Square%20%7C%20Adversarial%20robustness%20(max%20perturbation)%20%7C%0A%20%20%20%20%7C%20%24L_p%24%20(general)%20%7C%20%24p%24%20%7C%20Interpolation%20between%20diamond%20and%20square%20%7C%20Elastic%20Net%20blends%20%24L_1%24%20and%20%24L_2%24%20%7C%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20Metric%3A%20Measuring%20%22Distance%22%20Between%20Two%20Points%0A%0A%20%20%20%20A%20**metric**%20%24d%20%3A%20X%20%5Ctimes%20X%20%5Cto%20%5Cmathbb%7BR%7D_%7B%5Cgeq%200%7D%24%20satisfies%3A%0A%0A%20%20%20%20%7C%20Axiom%20%7C%20Formula%20%7C%0A%20%20%20%20%7C%20%3A---%20%7C%20%3A---%20%7C%0A%20%20%20%20%7C%20**Non-negativity**%20%7C%20%24d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7By%7D)%20%5Cgeq%200%24%20%7C%0A%20%20%20%20%7C%20**Identity%20of%20indiscernibles**%20%7C%20%24d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7By%7D)%20%3D%200%20%5Ciff%20%5Cmathbf%7Bx%7D%20%3D%20%5Cmathbf%7By%7D%24%20%7C%0A%20%20%20%20%7C%20**Symmetry**%20%7C%20%24d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7By%7D)%20%3D%20d(%5Cmathbf%7By%7D%2C%20%5Cmathbf%7Bx%7D)%24%20%7C%0A%20%20%20%20%7C%20**Triangle%20inequality**%20%7C%20%24d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7Bz%7D)%20%5Cleq%20d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7By%7D)%20%2B%20d(%5Cmathbf%7By%7D%2C%20%5Cmathbf%7Bz%7D)%24%20%7C%0A%0A%20%20%20%20Every%20norm%20induces%20a%20metric%20via%20%24d(%5Cmathbf%7Bx%7D%2C%20%5Cmathbf%7By%7D)%20%3D%20%5C%7C%5Cmathbf%7Bx%7D%20-%20%5Cmathbf%7By%7D%5C%7C%24%2C%20but%20not%20every%20metric%20comes%20from%20a%20norm%20(e.g.%2C%20edit%20distance%20on%20strings%2C%20Jaccard%20distance%20on%20sets).%0A%0A%20%20%20%20%23%23%23%20The%20Minkowski%20Inequality%3A%20%24L_2%20%5Cleq%20L_1%24%0A%0A%20%20%20%20For%20any%20two%20points%2C%20the%20Euclidean%20distance%20is%20always%20less%20than%20or%20equal%20to%20the%20Manhattan%20distance%3A%0A%20%20%20%20%24%24%0A%20%20%20%20%5C%7C%5Cmathbf%7Bx%7D%20-%20%5Cmathbf%7By%7D%5C%7C_2%20%5Cleq%20%5C%7C%5Cmathbf%7Bx%7D%20-%20%5Cmathbf%7By%7D%5C%7C_1%0A%20%20%20%20%24%24%0A%0A%20%20%20%20This%20follows%20from%20the%20Cauchy-Schwarz%20inequality%20and%20has%20practical%20consequences%3A%20a%20nearest-neighbor%20search%20with%20%24L_1%24%20is%20more%20conservative%20(larger%20distances)%20than%20with%20%24L_2%24.%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20Role%20in%20ML%20%2F%20AI%20%2F%20Stats%0A%0A%20%20%20%20%7C%20Context%20%7C%20Norm%2FMetric%20Used%20%7C%20Why%20%7C%0A%20%20%20%20%7C%20%3A---%20%7C%20%3A---%20%7C%20%3A---%20%7C%0A%20%20%20%20%7C%20**MSE%20Loss**%20%7C%20%24%5C%7C%5Cmathbf%7By%7D%20-%20%5Chat%7B%5Cmathbf%7By%7D%7D%5C%7C_2%5E2%24%20%7C%20Penalizes%20large%20errors%20quadratically%20%7C%0A%20%20%20%20%7C%20**MAE%20Loss**%20%7C%20%24%5C%7C%5Cmathbf%7By%7D%20-%20%5Chat%7B%5Cmathbf%7By%7D%7D%5C%7C_1%24%20%7C%20Robust%20to%20outliers%20(linear%20penalty)%20%7C%0A%20%20%20%20%7C%20**Ridge%20Regression**%20%7C%20%24%5Clambda%5C%7C%5Cmathbf%7Bw%7D%5C%7C_2%5E2%24%20%7C%20Shrinks%20all%20weights%20uniformly%20%7C%0A%20%20%20%20%7C%20**Lasso%20Regression**%20%7C%20%24%5Clambda%5C%7C%5Cmathbf%7Bw%7D%5C%7C_1%24%20%7C%20Drives%20irrelevant%20weights%20to%20exact%20zero%20%7C%0A%20%20%20%20%7C%20**Gradient%20Clipping**%20%7C%20%24%5Ctext%7Bclip%7D(%5Cnabla%2C%20%5C%7C%5Cnabla%5C%7C_2%20%5Cleq%20c)%24%20%7C%20Prevents%20exploding%20gradients%20in%20RNNs%2FTransformers%20%7C%0A%20%20%20%20%7C%20**KNN%20%2F%20DBSCAN**%20%7C%20%24%5C%7C%5Cmathbf%7Bx%7D_i%20-%20%5Cmathbf%7Bx%7D_j%5C%7C_p%24%20%7C%20Defines%20neighborhoods%20for%20classification%2Fclustering%20%7C%0A%20%20%20%20%7C%20**Adversarial%20Robustness**%20%7C%20%24%5C%7C%5Cboldsymbol%7B%5Cdelta%7D%5C%7C_%5Cinfty%20%5Cleq%20%5Cepsilon%24%20%7C%20Bounds%20worst-case%20pixel%20perturbation%20%7C%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bc%5D%20Code%20Examples%0A%0A%20%20%20%20%23%23%23%20Example%201%3A%20Visualizing%20Unit%20Norm%20%22Circles%22%20for%20Different%20%24p%24-Norms%0A%0A%20%20%20%20The%20unit%20norm%20set%20%24%5C%7B%5Cmathbf%7Bx%7D%20%3A%20%5C%7C%5Cmathbf%7Bx%7D%5C%7C_p%20%3D%201%5C%7D%24%20reveals%20the%20geometry%20each%20norm%20imposes%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20plotly.graph_objects%20as%20go%0A%0A%20%20%20%20return%20go%2C%20np%0A%0A%0A%40app.cell%0Adef%20_(go%2C%20np)%3A%0A%20%20%20%20def%20unit_circle(p%2C%20num_points%3D1000)%3A%0A%20%20%20%20%20%20%20%20%22%22%22Compute%20the%20unit%20circle%20boundary%20for%20L_p%20norm.%22%22%22%0A%20%20%20%20%20%20%20%20if%20p%20%3D%3D%20np.inf%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20x%20%3D%20np.array(%5B1%2C%201%2C%20-1%2C%20-1%2C%201%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20y%20%3D%20np.array(%5B1%2C%20-1%2C%20-1%2C%201%2C%201%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20x%2C%20y%0A%20%20%20%20%20%20%20%20x%20%3D%20np.linspace(-1%2C%201%2C%20num_points)%0A%20%20%20%20%20%20%20%20y_pos%20%3D%20np.maximum(0%2C%201%20-%20np.abs(x)%20**%20p)%20**%20(1%20%2F%20p)%0A%20%20%20%20%20%20%20%20y_neg%20%3D%20-y_pos%0A%20%20%20%20%20%20%20%20return%20np.concatenate(%5Bx%2C%20x%5B%3A%3A-1%5D%5D)%2C%20np.concatenate(%5By_pos%2C%20y_neg%5D)%0A%0A%20%20%20%20fig%20%3D%20go.Figure()%0A%0A%20%20%20%20norms%20%3D%20%5B%0A%20%20%20%20%20%20%20%20(0.5%2C%20%22%239b59b6%22%2C%20%22p%20%3D%200.5%20(quasi-norm)%22)%2C%0A%20%20%20%20%20%20%20%20(1%2C%20%22%23e74c3c%22%2C%20%22L%E2%82%81%3A%20Diamond%20(Lasso)%22)%2C%0A%20%20%20%20%20%20%20%20(2%2C%20%22%233498db%22%2C%20%22L%E2%82%82%3A%20Circle%20(Ridge)%22)%2C%0A%20%20%20%20%20%20%20%20(4%2C%20%22%23e67e22%22%2C%20%22L%E2%82%84%3A%20Rounded%20square%22)%2C%0A%20%20%20%20%20%20%20%20(np.inf%2C%20%22%232ecc71%22%2C%20%22L_%E2%88%9E%3A%20Square%20(Adversarial)%22)%2C%0A%20%20%20%20%5D%0A%0A%20%20%20%20for%20p%2C%20color%2C%20label%20in%20norms%3A%0A%20%20%20%20%20%20%20%20x%2C%20y%20%3D%20unit_circle(p)%0A%20%20%20%20%20%20%20%20fig.add_trace(go.Scatter(x%3Dx%2C%20y%3Dy%2C%20mode%3D%22lines%22%2C%20name%3Dlabel%2C%20line%3Ddict(color%3Dcolor%2C%20width%3D2.5)))%0A%0A%20%20%20%20fig.update_layout(%0A%20%20%20%20%20%20%20%20title%3Ddict(text%3D%22Unit%20Norm%20Sets%3A%20How%20Different%20p-Norms%20Define%20Distance%20%3D%201%22%2C%20font%3Ddict(size%3D14))%2C%0A%20%20%20%20%20%20%20%20xaxis%3Ddict(title%3D%22x%E2%82%81%22%2C%20range%3D%5B-1.6%2C%201.6%5D%2C%20zeroline%3DTrue%2C%20gridcolor%3D%22%23e5e5e5%22%2C%20scaleanchor%3D%22y%22%2C%20scaleratio%3D1)%2C%0A%20%20%20%20%20%20%20%20yaxis%3Ddict(title%3D%22x%E2%82%82%22%2C%20range%3D%5B-1.6%2C%201.6%5D%2C%20zeroline%3DTrue%2C%20gridcolor%3D%22%23e5e5e5%22)%2C%0A%20%20%20%20%20%20%20%20template%3D%22plotly_white%22%2C%0A%20%20%20%20%20%20%20%20legend%3Ddict(x%3D0.68%2C%20y%3D0.98)%2C%0A%20%20%20%20%20%20%20%20width%3D600%2C%0A%20%20%20%20%20%20%20%20height%3D600%2C%0A%20%20%20%20)%0A%0A%20%20%20%20fig%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%23%20Example%202%3A%20Euclidean%20vs%20Manhattan%20Distance%3A%20The%20Minkowski%20Inequality%20in%20Action%0A%0A%20%20%20%20For%20random%202D%20vector%20pairs%2C%20Euclidean%20distance%20is%20always%20%24%5Cleq%24%20Manhattan%20distance%3A%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(go%2C%20np)%3A%0A%20%20%20%20rng%20%3D%20np.random.default_rng(47)%0A%20%20%20%20points1%20%3D%20rng.integers(-3%2C%204%2C%20size%3D(200%2C%202))%0A%20%20%20%20points2%20%3D%20rng.integers(-3%2C%204%2C%20size%3D(200%2C%202))%0A%0A%20%20%20%20d_euclidean%20%3D%20np.sqrt(np.sum((points2%20-%20points1)%20**%202%2C%20axis%3D1))%0A%20%20%20%20d_manhattan%20%3D%20np.sum(np.abs(points2%20-%20points1)%2C%20axis%3D1)%0A%0A%20%20%20%20max_val%20%3D%20float(max(d_manhattan.max()%2C%20d_euclidean.max())%20%2B%200.5)%0A%0A%20%20%20%20fig2%20%3D%20go.Figure()%0A%20%20%20%20fig2.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dd_euclidean%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Dd_manhattan%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22markers%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22Vector%20pairs%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker%3Ddict(color%3D%22%231B7A7A%22%2C%20size%3D7%2C%20opacity%3D0.7%2C%20line%3Ddict(color%3D%22black%22%2C%20width%3D0.5))%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20fig2.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%5B0%2C%20max_val%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%5B0%2C%20max_val%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22lines%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22d_L%E2%82%82%20%3D%20d_L%E2%82%81%20(equality%20line)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%23D65A31%22%2C%20dash%3D%22dash%22%2C%20width%3D2)%2C%0A%20%20%20%20%20%20%20%20)%0A%20%20%20%20)%0A%20%20%20%20fig2.update_layout(%0A%20%20%20%20%20%20%20%20title%3Ddict(%0A%20%20%20%20%20%20%20%20%20%20%20%20text%3D%22Minkowski%20Inequality%3A%20%7C%7Cx%7C%7C%E2%82%82%20%E2%89%A4%20%7C%7Cx%7C%7C%E2%82%81%20(all%20points%20on%20or%20above%20equality%20line)%22%2C%20font%3Ddict(size%3D13)%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20xaxis%3Ddict(title%3D%22Euclidean%20Distance%20(L%E2%82%82)%22%2C%20zeroline%3DTrue%2C%20gridcolor%3D%22%23e5e5e5%22)%2C%0A%20%20%20%20%20%20%20%20yaxis%3Ddict(title%3D%22Manhattan%20Distance%20(L%E2%82%81)%22%2C%20zeroline%3DTrue%2C%20gridcolor%3D%22%23e5e5e5%22)%2C%0A%20%20%20%20%20%20%20%20template%3D%22plotly_white%22%2C%0A%20%20%20%20%20%20%20%20width%3D650%2C%0A%20%20%20%20%20%20%20%20height%3D550%2C%0A%20%20%20%20)%0A%0A%20%20%20%20fig2%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bd%5D%20Takeaway%0A%0A%20%20%20%20-%20A%20**norm**%20measures%20the%20size%20of%20a%20vector%3B%20a%20**metric**%20measures%20the%20distance%20between%20two%20vectors.%20Every%20norm%20induces%20a%20metric%2C%20but%20not%20vice%20versa.%0A%20%20%20%20-%20The%20%24L_p%24%20norm%20family%20(%24p%20%3D%201%2C%202%2C%20%5Cinfty%24)%20controls%20the%20**geometry%20of%20your%20model**%3A%20%24L_1%24%20encourages%20sparsity%20(Lasso)%2C%20%24L_2%24%20encourages%20small%20uniform%20weights%20(Ridge)%2C%20and%20%24L_%5Cinfty%24%20bounds%20worst-case%20deviations%20(adversarial%20robustness).%0A%20%20%20%20-%20**Euclidean%20distance%20is%20always%20%E2%89%A4%20Manhattan%20distance**%20(Minkowski%20inequality)%2C%20which%20affects%20nearest-neighbor%20search%20behavior%20and%20distance-based%20clustering.%0A%20%20%20%20-%20In%20practice%2C%20the%20**choice%20of%20norm%20is%20a%20modeling%20decision**%3A%20it%20determines%20how%20errors%20are%20penalized%20(loss)%2C%20how%20parameters%20are%20constrained%20(regularization)%2C%20and%20what%20%22nearby%22%20means%20(retrieval).%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%26larr%3B%20Previous%20Note%3A%20%5B01%20Inner%20Products%5D(01_inner_product.py)%20%7C%20Next%20Note%3A%20%5B03%20Hyperplanes%5D(03_hyperplanes.py)%20%26rarr%3B%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
d3fc9386fde0d8ca42068555fa6473c7