UNPKG

1.85 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6
7var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
8
9function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
10
11/**
12 * Base class for clustering algorithms.
13 */
14var Clusterer = function () {
15 function Clusterer() {
16 _classCallCheck(this, Clusterer);
17 }
18
19 _createClass(Clusterer, [{
20 key: 'train',
21
22 /**
23 * Run the clustering algorithm on a dataset and obtain the cluster predictions per class.
24 *
25 * @abstract
26 *
27 * @param {Array.<Array.<number>>} X - Features per data point
28 */
29 value: function train(X) {
30 throw new Error('Method must be implemented child class.');
31 }
32
33 /**
34 * Assign clusters to samples.
35 *
36 * @param {Array.<Array.<number>>} X - Features per data point
37 * @return {Array.<Number>} Cluster indices assigned to input data points. For n input data
38 * points, an n-dimensional array containing the cluster assignments will be returned
39 */
40
41 }, {
42 key: 'cluster',
43 value: function cluster(X) {
44 throw new Error('Method must be implemented child class.');
45 }
46 }]);
47
48 return Clusterer;
49}();
50
51exports.default = Clusterer;
52module.exports = exports.default;
\No newline at end of file