Source: ml/Model.js

  1. /*
  2. * Copyright 2016 IBM Corp.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. module.exports = function(kernelP) {
  17. return (function() {
  18. var Utils = require('../utils.js');
  19. var Transformer = require('./Transformer')();
  20. /**
  21. * @classdesc
  22. * A fitted model, i.e., a {@link module:eclairjs/ml.Transformer} produced by an {@link module:eclairjs/ml.Estimator}.
  23. *
  24. * @class
  25. * @memberof module:eclairjs/ml
  26. * @extends module:eclairjs/ml.Transformer
  27. */
  28. function Model() {
  29. Utils.handleAbstractConstructor(this, arguments);
  30. }
  31. Model.prototype = Object.create(Transformer.prototype);
  32. Model.prototype.constructor = Model;
  33. /**
  34. * Sets the parent of this model.
  35. * @param {module:eclairjs/ml.Estimator} parent
  36. * @returns {object}
  37. */
  38. Model.prototype.setParent = function(parent) {
  39. var args = {
  40. target: this,
  41. method: 'setParent',
  42. args: Utils.wrapArguments(arguments),
  43. returnType: Utils.getContextClass(this)
  44. };
  45. return Utils.generate(args);
  46. };
  47. /**
  48. *
  49. * @returns {module:eclairjs/ml.Estimator}
  50. */
  51. Model.prototype.parent = function() {
  52. var Estimator = require('./Estimator')();
  53. var args = {
  54. target: this,
  55. method: 'parent',
  56. args: Utils.wrapArguments(arguments),
  57. returnType: Estimator
  58. };
  59. return Utils.generate(args);
  60. };
  61. /**
  62. * Indicates whether this {@link Model} has a corresponding parent.
  63. * @returns {Promise.<boolean>}
  64. */
  65. Model.prototype.hasParent = function() {
  66. var args = {
  67. target: this,
  68. method: 'hasParent',
  69. args: Utils.wrapArguments(arguments),
  70. returnType: Boolean
  71. };
  72. return Utils.generate(args);
  73. };
  74. /**
  75. * @param {module:eclairjs/ml/param.ParamMap} extra
  76. * @returns {object}
  77. */
  78. Model.prototype.copy = function(extra) {
  79. var args = {
  80. target: this,
  81. method: 'copy',
  82. args: Utils.wrapArguments(arguments),
  83. returnType: Utils.getContextClass(this)
  84. };
  85. return Utils.generate(args);
  86. };
  87. return Model;
  88. })();
  89. };