# import libraries import matplotlib.pyplot as plt from sklearn.datasets import make_moons from sklearn.cluster import DBSCAN from sklearn.preprocessing import StandardScaler # Generate non-linear, real-world like unlabeled data X, _ = make_moons( n_samples=500, noise=0.08, random_state=42 ) # Feature scaling (important for DBSCAN) scaler = StandardScaler() X_scaled = scaler.fit_transform(X) # Apply DBSCAN dbscan = DBSCAN(eps=0.3, min_samples=5) clusters = dbscan.fit_predict(X_scaled) # Visualizing clusters plt.figure(figsize=(8, 6)) plt.scatter( X_scaled[:, 0], X_scaled[:, 1], c=clusters, cmap='rainbow', s=60 ) plt.title("DBSCAN Clustering on Unlabeled Data") plt.xlabel("Feature 1 (scaled)") plt.ylabel("Feature 2 (scaled)") plt.show() __ __