# Proper dataset format for K-Means and DBSCAN clusterers

I'm trying to classify web traffic using clustering algorithms with my own C program, capturing packets with libpcap. In this article K-Means, DBSCAN and AutoClass algorithms were used to classify web traffic.

I tested my dataset with different implementations of K-Means and DBSCAN, yet it is unclear to me how these two algorithms deal with data:

in K-Means from a C clustering library, the dataset is a matrix of double** where the rows are the points of observation and the columns are the features; this data struct suits me fine, in my code every row is a connection and every column is a feature (delay, or average dimension, or bps, ...) of it;

in DBSCAN from a git repo the dataset is an int ** matrix;

in another DBSCAN repo there is no matrix of features like above, but a linked list of struct point with double x, y coordinates.

I'm confused about the dataset representation: in my program, for every connection (row) there are a number of features (columns), but this representation seems to not agree with a linked list of points like in the second implementation of DBSCAN: should I convert the K-Means dataset implemented as a matrix in a linked list of struct point for DBSCAN?

I know this seems a CodeReview question but I want to figure this out.

k-means needs to compute means.

Therefore, it only works on a vector space.

DBSCAN (see Generalized DBSCAN) needs:

• a neighborhood query (typically radius based but can be anything)
• a decision if a point is "core point" or not (typically based on the number of neighbors)

it is thus much more general. The implemetations you looked at probably were not very good.

• So I can picture my K-Means nxm matrix as a DBSCAN set of n points with m dimensions each? – elmazzun Feb 1 '16 at 14:23
• K-Means expects a nxm matrix. DBSCAN does not: it could process e.g. polygons, or CAD objects, or images, or audio signals, or text, or a graph, or ... if you you Euclidean distance, it will of course work with a nxm matrix, too. – Has QUIT--Anony-Mousse Feb 1 '16 at 16:46