@jsmlt/jsmlt
Version:
JavaScript Machine Learning
85 lines (68 loc) • 2.49 kB
JavaScript
;
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"); } }
/**
* Datapoint in a dataset, with features and possibly a class index. Can be used as the model for
* UI data points.
*/
var Datapoint = 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"];