Giter VIP home page Giter VIP logo

kmeans_task's Introduction

TASK For Interview

Estimated Time to Finish

I have spent 2 hours. Once I have finished the 1st hour, I tried to upload the code first as an attachments, but there was an error in the Gmail through linkedIn. It doesn't accept attached files (I figured it out later). Therefore I have uploaded the project to my GitHub.

- TASK

Given a set of two dimensional points P (e.g. ....) find the size of set can be (100s).

  • Write a function that calculates simple K-means, the expected returned value from the function are:
  1. a Aet of cluster ID that each point belongs to
  2. coordinates of centroids at the end of iteration.

- RESPONSE

python ProjectFiles/Task1.py

First we show a test of the kMeans algorithm

Using an assumed values such as:

X = np.array([[1.1,2.5],
              [3.4,1.9],
              [5,8],
              [8,8],
              [1,0.6],
              [9,11]])

We can get the centroids of two groups classification -Showed in black color Group 0- in Green color, Group 1- in Red color

Ouput

Classifying the featureset of given observations to which group it belongs.

the featureset of 1.1,2.5 belong to Group0
the featureset of 3.4,1.9 belong to Group0
the featureset of 1.0,0.6 belong to Group0
the featureset of 5.0,8.0 belong to Group1
the featureset of 8.0,8.0 belong to Group1
the featureset of 9.0,11.0 belong to Group1

And with centroids as

=====Centroid of group0=1.8333333333333333,1.6666666666666667
=====Centroid of group1=7.333333333333333,9.0

Bonus

We proceed with the algorithm to use it with a sample size of 100 points. I have generated 100 points using the following library

sklearn.datasets.samples_generator

Since the points are random and they can change everytime you run the code I here show for two group an example:

and for three groups

NOTE

I can refine the algorithm more but up to this point I hope it will be sufficient for the testing purpose.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.