2

scikit-learn: Mean Shift Clustering

Unsolved
Unsupervised

Difficulty: 2 | Problem written by zeyad_omar

Educational Resource: https://towardsdatascience.com/a-beginners-guide-to-scikit-learn-14b7e51d71a4


Problem reported in interviews at

Netflix

Mean shift clustering is an unsupervised learning algorithm that tries to shift the centroids (center of clusters) towards the mean of the surronding data points.

In this problem, you are asked to use sklearn to implement mean shift clustring algorithm given X_train to predict the labels of X_test.

Please use bandwidth=1 as a parameter for the model to match the output of the test cases.

Sample Input:
<class 'list'>
X_train: [[1, 1], [2, 1], [1, 0], [4, 7], [3, 5], [3, 6]]
X_test: [[0, 0], [5, 5]]

Expected Output:
<class 'numpy.ndarray'>
[0 1]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Autem adipisci magnam optio voluptatem fugiat quidem quibusdam sit sequi, fugiat corporis cumque maxime dicta distinctio, neque dolor inventore obcaecati iste quam?

Laboriosam tempore ad nemo, repudiandae possimus officia sed mollitia iste illum, eligendi saepe cum tenetur odio dolorum, harum placeat earum, eum sit optio error provident esse distinctio dolores perspiciatis necessitatibus consectetur. Amet quidem qui ex praesentium, quidem inventore perferendis, dolore et ipsam consectetur suscipit architecto tempore quia hic minus? Nemo soluta fugiat harum, delectus nihil explicabo, debitis autem doloremque deleniti? Incidunt iusto non vitae blanditiis eveniet animi, vero possimus consequuntur sunt architecto hic, impedit quam debitis libero a dignissimos?

Id tempore assumenda veritatis, saepe nihil ut temporibus culpa cumque cupiditate expedita animi, nesciunt repellat vero molestiae, exercitationem laboriosam officiis velit eaque, adipisci dolore dolor minima assumenda ratione quasi praesentium odit aliquam ab. Nobis libero distinctio corrupti ex eaque placeat vel eligendi, nostrum porro facere doloribus labore repudiandae blanditiis officiis, quaerat in dolorum, ipsa ipsum sed nemo dignissimos natus quibusdam placeat?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)