@jsmlt/jsmlt
Version:
JavaScript Machine Learning
56 lines (46 loc) • 1.87 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/**
* Base class for clustering algorithms.
*/
var Clusterer =
/*#__PURE__*/
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;