UNPKG

@jsmlt/jsmlt

Version:

JavaScript Machine Learning

87 lines (72 loc) 2.5 kB
"use strict"; 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; } /** * Datapoint in a dataset, with features and possibly a class index. Can be used as the model for * UI data points. */ var Datapoint = /*#__PURE__*/ function () { /** * Constructor. Load data point features. * * @param {Array.<number>} features - Data point features array */ function Datapoint(features) { _classCallCheck(this, Datapoint); this.features = features; // Data point features array this.classIndex = null; // Index of data point's class // "marked" status of data point. Can be used e.g. to indicate support vectors this.marked = false; } /** * Change the class index of this data point. * * @param {mixed} classIndex - New class index */ _createClass(Datapoint, [{ key: "setClassIndex", value: function setClassIndex(classIndex) { this.classIndex = classIndex; } /** * Get the class index of this data point. * * @return {mixed} Class index */ }, { key: "getClassIndex", value: function getClassIndex() { return this.classIndex; } /** * Change the "marked" status of this data point. Can be used for e.g. support vectors. * * @param {boolean} marked - Whether the data point should be marked or not */ }, { key: "setMarked", value: function setMarked(marked) { this.marked = marked; } /** * Check whether the data point is marked. * * @return {boolean} - Whether the data point is marked */ }, { key: "isMarked", value: function isMarked() { return this.marked; } }]); return Datapoint; }(); exports["default"] = Datapoint; module.exports = exports.default;