UNPKG

@jsmlt/jsmlt

Version:

JavaScript Machine Learning

52 lines (42 loc) 1.85 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _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; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Base class for clustering algorithms. */ var Clusterer = function () { function Clusterer() { _classCallCheck(this, Clusterer); } _createClass(Clusterer, [{ key: 'train', /** * Run the clustering algorithm on a dataset and obtain the cluster predictions per class. * * @abstract * * @param {Array.<Array.<number>>} X - Features per data point */ value: function train(X) { throw new Error('Method must be implemented child class.'); } /** * Assign clusters to samples. * * @param {Array.<Array.<number>>} X - Features per data point * @return {Array.<Number>} Cluster indices assigned to input data points. For n input data * points, an n-dimensional array containing the cluster assignments will be returned */ }, { key: 'cluster', value: function cluster(X) { throw new Error('Method must be implemented child class.'); } }]); return Clusterer; }(); exports.default = Clusterer; module.exports = exports['default'];