Project in Data Handling in Physics.
Implemented three different clustering algorithms on measured data.

Goal: determining cluster of origin for data points.

Achived through the k-means algorithm, Agglomerative clustering and EM-algorithm.

generalized to work in N-dimentions on M-measurments.

With graphic representation in the spesific case of 4-dimentions and 150 measurements.

Imported data from "iris.dat" containing the famous measurments of petal and sepal size from three diferent iris species.

Then performed the k-means clustering algorithm with 3 cluster.

- Initialize cluster with random assignment of cluster-lables to all points.
- Calculate the k cluster centroids(average value in each dimention)
- Update cluster-lable according to closest centroid
- Repeat until nothing changes between iterations.

This classifier gives 82% correct classification.

Code can be run in root with command: ".x K_Means.C".

Code can be seen here

Also have an example with three distinct gaussian distributed clusters which gives a 100% correct classification.

Code for that can be seen here

Again imported data from "iris.dat" containing the famous measurments of petal and sepal size from three diferent iris species.

Then performed Agglomerative clustering until there were 3 clusters left.

- Assign a cluster to each datapoint.
- Calculate the all to all cluster distance (used average distance when more then one point)
- Merged the clusters closest to each other
- Repeat until only three left.

This classifier gives 83.3% correct classification.

Code can be run in root with command: ".x clustering2.C".

Code can be seen here

Also have an example with three distinct gaussian distributed clusters which gives a 100% correct classification.

Code for that can be seen here

Again imported data from "iris.dat".

Then performed EM algorithm to generate three gaussian clusters.

- Created three gaussian distribution with the three means initialized from one measurment from each species.

and gave them the standard deviation of 1. - The probability of each point belonging to a given distribution is calculated through:

And classified as the cluster with the highest probability. - Then calculating the mean:

and standard deviation:

of each cluster. - Repeat step 2 and 3 until there is no change.

Histogram of data set with the sum of the three gaussian distribution. Amplitude fitted to the histograms.

Graph of the three gaussian distribution in the 4 dimentions.

* In the second image the green graph is behind the blue.

This classifier gives 94% correct classification.

Code can be run in root with command: ".x EM_alg.C".

Code can be seen here

Suspecting something with me not deleting allocated memory(should be deleted on exiting the program).

Work which have been abandoned due to time constraint, but some of it is still good:

- k_means2.C Gives out the fit of three gaussian curves to the histograms, with 12 degrees of freedom(mean,sd and amplitude)

But this cant be used as a classifier since some of the amplidudes are negative. - One dimentional gaussian classifier for the iris data set:

Gives 72.7% correct classification. Code here.

- Attempt to draw the ellipse given by the covariance of a two dimentional gaussian distribution.

TO DO: figure out the angle. Example form the file draw_ellipse_example.C.