अपने clustering का निरीक्षण करें
आइए अब पिछले अभ्यास में किए गए clustering का निरीक्षण करें!
पिछले अभ्यास का समाधान पहले ही चल चुका है, इसलिए new_points पॉइंट्स का एक array है और labels उनके क्लस्टर लेबल्स का array है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Unsupervised Learning
अभ्यास निर्देश
matplotlib.pyplotकोpltनाम से इम्पोर्ट करें.new_pointsके कॉलम0कोxsऔर कॉलम1कोysमें असाइन करें.xsऔरysका एक scatter plot बनाएँ, और पॉइंट्स को उनके क्लस्टर लेबल के अनुसार रंगने के लिएc=labelsकीवर्ड आर्ग्यूमेंट दें. साथ हीalpha=0.5भी निर्दिष्ट करें.modelके.cluster_centers_एट्रिब्यूट का उपयोग करके centroids के कोऑर्डिनेट्स compute करें.centroidsके कॉलम0कोcentroids_xऔर कॉलम1कोcentroids_yमें असाइन करें.centroids_xऔरcentroids_yका एक scatter plot बनाएँ, औरmarkerपैरामीटर देकर'D'(हीरे का आकार) मार्कर इस्तेमाल करें. मार्कर्स का आकारs=50देकर50सेट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Import pyplot
____
# Assign the columns of new_points: xs and ys
xs = ____
ys = ____
# Make a scatter plot of xs and ys, using labels to define the colors
____
# Assign the cluster centers: centroids
centroids = ____
# Assign the columns of centroids: centroids_x, centroids_y
centroids_x = centroids[:,0]
centroids_y = centroids[:,1]
# Make a scatter plot of centroids_x and centroids_y
____
plt.show()