CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 21:15:54 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=053f72039435630b0ef82c4319aed0d1ce59287cc12f8b007bc813a813a3f47ba%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22xS6dOu_wpqcpnfc3qaXL0lLOwZJGuvDX%22%3B%7D; HttpOnly; Path=/
cf-ray: 98d160207e062ffb-BLR
Lab_ML(03/02/25) - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- from scipy.spatial.distance import euclidean, cityblock, chebyshev, minkowski, hamming, cosine, jaccard
- # Define the two points for Euclidean, Manhattan, Chebyshev, and Minkowski
- point1 = (1, 2)
- point2 = (4, 6)
- # Define binary vectors for Hamming
- point1_binary = np.array([1, 0, 1, 0])
- point2_binary = np.array([1, 1, 0, 0])
- # Define vectors for Cosine
- point1_vector = np.array([1, 2, 3])
- point2_vector = np.array([4, 6, 8])
- # Define sets for Jaccard and convert them to binary vectors
- point1_set = set([1, 2, 3])
- point2_set = set([3, 4, 5])
- # Convert sets to binary vectors
- all_elements = point1_set.union(point2_set)
- point1_binary_vector = np.array([1 if x in point1_set else 0 for x in all_elements])
- point2_binary_vector = np.array([1 if x in point2_set else 0 for x in all_elements])
- # List of distance functions and their names
- distance_functions = [
- ("Euclidean", euclidean, point1, point2),
- ("Manhattan", cityblock, point1, point2),
- ("Chebyshev", chebyshev, point1, point2),
- ("Minkowski (p=3)", lambda p1, p2: minkowski(p1, p2, p=3), point1, point2),
- ("Hamming", hamming, point1_binary, point2_binary),
- ("Cosine", cosine, point1_vector, point2_vector),
- ("Jaccard", jaccard, point1_binary_vector, point2_binary_vector)
- ]
- # Calculate distances and store them
- distances = []
- for name, distance_func, p1, p2 in distance_functions:
- distance = distance_func(p1, p2)
- distances.append((name, distance))
- print(f"{name} distance:", distance)
- # Plot the distances using a bar chart
- fig, ax = plt.subplots(figsize=(10, 6))
- distance_names = [d[0] for d in distances]
- distance_values = [d[1] for d in distances]
- bars = ax.bar(distance_names, distance_values, color='skyblue')
- ax.set_xlabel('Distance Metrics')
- ax.set_ylabel('Distance Values')
- ax.set_title('Comparison of Different Distance Metrics')
- # Set the tick positions and labels explicitly
- ax.set_xticks(range(len(distance_names)))
- ax.set_xticklabels(distance_names, rotation=45, ha='right')
- # Add value labels on top of the bars
- for bar in bars:
- yval = bar.get_height()
- ax.text(bar.get_x() + bar.get_width()/2, yval + 0.05, round(yval, 2), ha='center', va='bottom')
- plt.tight_layout()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐✅ Swapzone Glitch ✅ Working ⭐⭐ 0
JavaScript | 2 sec ago | 0.25 KB
-
✅⭐ Make huge profits on trading ⭐⭐ 5
JavaScript | 8 sec ago | 0.25 KB
-
⭐⭐⭐Exchange Exploit T I⭐⭐
Java | 8 sec ago | 0.10 KB
-
✅ Make $2500 in 20 minutes⭐⭐⭐ 4
JavaScript | 12 sec ago | 0.25 KB
-
📌 Instant BTC Profit Method ✅ Working
JavaScript | 15 sec ago | 0.24 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 17 sec ago | 0.25 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 21 sec ago | 0.10 KB
-
📌 Swapzone +37% glitch ⭐ V
JavaScript | 21 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand