# dbscan

> dbscan clustering algorithm

Latest version **0.0.1** (published 2014-09-16) · BSD license · 0 weekly downloads

## Install

```sh
npm install dbscan
pnpm add dbscan
yarn add dbscan
bun add dbscan
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2014-09-16 |
| First published | 2014-09-16 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Gil Tamari |
| Maintainers | xmen4u |
| Keywords | dbscan, cluster, unsupervized |

## Links

- npm: https://www.npmjs.com/package/dbscan
- npm.io page: https://npm.io/package/dbscan

## Dependencies (2)

- [jshint](https://npm.io/package/jshint.md) ^2.5.5
- [matchdep](https://npm.io/package/matchdep.md) ^0.3.0

## Recent versions

- 0.0.1 (latest) — 2014-09-16

## README

Clustering - DBScan algorithm
==============================

A node module, that uses DBScan unsupervised clustering algorithm, to return centroids and their cluster

This algorithm doesn't handle well the following:


1. Large datasets [computational complexity]
2. Number of dimensions ( > 16) - more computaitons, "curse of dimensionality"

about (2), given a fixed amount of points, the density of the points decreases exponentially.  Meaning you won't be able 
to find cluster as you'll be wandering a lot.
About "the curse", it means that 
Complexity: O(n^2) - space, O(n^2) - time



You'll find a pre-made 100 points 16-features vector sample file
Uses stream, readline node modules


using jSHint, matchdep , stream, grunt.js 

Use this with my permission only

ToC
---------------------

1. [Main app](#main)


<a name="main">Main app</a>
---------------------



points over map:

![](https://raw.githubusercontent.com/xmen4u/dbscan/master/img1.png)

![](https://raw.githubusercontent.com/xmen4u/dbscan/master/img2.png)


Initialization

we need to initialize the distance object, you can add any distance metric you wish 
to distance.js
```
var Distance 	 = require("./lib/distance"),
	distances    = new Distance(),
	// DBScan section
	DBScan       = require('./lib/dbscan.js'),
	dbscan       = new DBScan(distances)
```
after initialization, you need to create a multi-dimensional vector, an array of arrays:
```[[1,2],[1,4],[2,5],[5,9],...,[10,12]]```

in code we grab it via stream from a line-by-line [newline] structured flat file [so we won't have limit on memory space]
```var fs           = require('fs'), // File section
	readline     = require('readline'), // using the UNSTABLE readline built-in node module
	// Stream section
	stream       = require('stream'),
	points       = [],
	rl, // read-line
	in_stream;
in_stream = fs.createReadStream('./points.txt'),
rl = readline.createInterface({
							input: in_stream,
							terminal: false
						  })

rl.on('line', function(line) {
	points.push(JSON.parse(line))
});
```
finally we run the clustering:
```
	var clustering_obj = dbscan.cluster(points,distanceFunction)
    console.log('FINISHED reading ' + points.length + ' and clustering them');
```

---
_Source: https://npm.io/package/dbscan · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
