Skip to content

Commit

Permalink
Update README and package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
sderosiaux committed Aug 16, 2015
1 parent f22dc92 commit a89662a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
29 changes: 12 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@ Simple implementation of the k-means clustering method.

# How to use

It's using ES6 (barely) syntax. Make sure to run it using Babel for instance.

```javascript
var kmeans = require('algo-kmeans');
var Point = require('algo-kmeans').Point;
import kmeans, { Point } from 'algo-kmeans';

// generate random points
var points = [];
const points = [];
for (var i = 100; i >= 0; i--) {
points.push(new Point(50 - Math.random() * 100,
50 - Math.random() * 100,
50 - Math.random() * 100));
50 - Math.random() * 100,
50 - Math.random() * 100));
};
// kmeans asking for 5 clusters
var clusters = kmeans(points, { nbClusters: 5 });
const clusters = kmeans(points, { nbClusters: 5 });
// clusters.centroid = { x, y, z }
// clusters.points = [ { x, y, z }, { x, y, z }, ... ]

// kmeans with 2 clusters which init centroid is predefined
var clusters = kmeans(points, { initCentroids: [ new Point(0, 5, 10), new Point(10, -12, 0)] });
const clusters = kmeans(points, {
initCentroids: [
new Point(0, 5, 10),
new Point(10, -12, 0)
]
});
```

# Install
Expand All @@ -37,15 +39,8 @@ npm install algo-kmeans
# Testing

```
npm run test
npm test
```

# TODO

- Reorganise structure (files, directories)
- Use full ES6 power
- Add eslint

# License

MIT
26 changes: 24 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "algo-kmeans",
"version": "0.0.6",
"description": "",
"description": "Simple implementation of the k-means clustering method.",
"main": "src/index.js",
"scripts": {
"test": "./node_modules/.bin/_mocha",
Expand All @@ -24,5 +24,27 @@
"eslint-plugin-react": "^3.2.3",
"mocha": "^2.2.5",
"webpack": "^1.11.0"
}
},
"directories": {
"test": "test"
},
"dependencies": {
"babel": "^5.4.7",
"babel-core": "^5.8.22",
"babel-eslint": "^4.0.8",
"babel-loader": "^5.3.2",
"chai": "^2.3.0",
"eslint": "^1.1.0",
"eslint-config-airbnb": "^0.0.7",
"eslint-plugin-react": "^3.2.3",
"webpack": "^1.11.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/chtefi/algo-kmeans.git"
},
"bugs": {
"url": "https://github.com/chtefi/algo-kmeans/issues"
},
"homepage": "https://github.com/chtefi/algo-kmeans#readme"
}

0 comments on commit a89662a

Please sign in to comment.