Source: ml/Predictor.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 Estimator = require('./Estimator')();
  20. /**
  21. * @classdesc
  22. * Abstraction for prediction problems (regression and classification).
  23. *
  24. * E.g., {@link VectorUDT} for vector features.
  25. * parameter to specify the concrete type.
  26. * parameter to specify the concrete type for the corresponding model.
  27. * @class
  28. * @memberof module:eclairjs/ml
  29. * @extends module:eclairjs/ml.Estimator
  30. */
  31. function Predictor() {
  32. Utils.handleAbstractConstructor(this, arguments);
  33. }
  34. Predictor.prototype = Object.create(Estimator.prototype);
  35. Predictor.prototype.constructor = Predictor;
  36. /**
  37. * @param {string} value
  38. * @returns {module:eclairjs/ml.Predictor}
  39. */
  40. Predictor.prototype.setLabelCol = function(value) {
  41. var args = {
  42. target: this,
  43. method: 'setLabelCol',
  44. args: Utils.wrapArguments(arguments),
  45. returnType: Utils.getContextClass(this)
  46. };
  47. return Utils.generate(args);
  48. };
  49. /**
  50. * @param {string} value
  51. * @returns {module:eclairjs/ml.Predictor}
  52. */
  53. Predictor.prototype.setFeaturesCol = function(value) {
  54. var args = {
  55. target: this,
  56. method: 'setFeaturesCol',
  57. args: Utils.wrapArguments(arguments),
  58. returnType: Utils.getContextClass(this)
  59. };
  60. return Utils.generate(args);
  61. };
  62. /**
  63. * @param {string} value
  64. * @returns {module:eclairjs/ml.Predictor}
  65. */
  66. Predictor.prototype.setPredictionCol = function(value) {
  67. var args = {
  68. target: this,
  69. method: 'setPredictionCol',
  70. args: Utils.wrapArguments(arguments),
  71. returnType: Utils.getContextClass(this)
  72. };
  73. return Utils.generate(args);
  74. };
  75. /**
  76. * @param {module:eclairjs/ml/param.ParamMap} extra
  77. * @returns {module:eclairjs/ml.Predictor}
  78. */
  79. Predictor.prototype.copy = function(extra) {
  80. var args = {
  81. target: this,
  82. method: 'copy',
  83. args: Utils.wrapArguments(arguments),
  84. returnType: Utils.getContextClass(this)
  85. };
  86. return Utils.generate(args);
  87. };
  88. /**
  89. * @param {module:eclairjs/sql/types.StructType} schema
  90. * @returns {module:eclairjs/sql/types.StructType}
  91. */
  92. Predictor.prototype.transformSchema = function(schema) {
  93. var StructType = require('../sql/types/StructType.js')();
  94. var args = {
  95. target: this,
  96. method: 'transformSchema',
  97. args: Utils.wrapArguments(arguments),
  98. returnType: StructType
  99. };
  100. return Utils.generate(args);
  101. };
  102. return Predictor;
  103. })();
  104. };