Source: ml/evaluation/RegressionEvaluator.js

/*
 * Copyright 2016 IBM Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

module.exports = function(kernelP) {
  return (function() {
    var Utils = require('../../utils.js');

    var gKernelP = kernelP;

    /**
     * :: Experimental ::
     * Evaluator for regression, which expects two input columns: prediction and label.
     * @classdesc
     */

    /**
     * @param {string} uid
     * @class
     * @constructor
     * @memberof module:eclairjs/ml/evaluation
     */
    function RegressionEvaluator() {
      Utils.handleConstructor(this, arguments, gKernelP);
    }

    /**
     * @returns {Promise.<string>}
     */
    RegressionEvaluator.prototype.getMetricName = function() {
      var args = {
        target: this,
        method: 'getMetricName',
        args: Utils.wrapArguments(arguments),
        returnType: String
      };

      return Utils.generate(args);
    };

    /**
     * @param {string} value
     * @returns {module:eclairjs/ml/evaluation.RegressionEvaluator}
     */
    RegressionEvaluator.prototype.setMetricName = function(value) {
      var args = {
        target: this,
        method: 'setMetricName',
        args: Utils.wrapArguments(arguments),
        returnType: RegressionEvaluator
      };

      return Utils.generate(args);
    };

    /**
     * @param {string} value
     * @returns {module:eclairjs/ml/evaluation.RegressionEvaluator}
     */
    RegressionEvaluator.prototype.setPredictionCol = function(value) {
      var args = {
        target: this,
        method: 'setPredictionCol',
        args: Utils.wrapArguments(arguments),
        returnType: RegressionEvaluator
      };

      return Utils.generate(args);
    };

    /**
     * @param {string} value
     * @returns {module:eclairjs/ml/evaluation.RegressionEvaluator}
     */
    RegressionEvaluator.prototype.setLabelCol = function(value) {
      var args = {
        target: this,
        method: 'setLabelCol',
        args: Utils.wrapArguments(arguments),
        returnType: RegressionEvaluator
      };

      return Utils.generate(args);
    };

    /**
     * @param {module:eclairjs/sql.Dataset} dataset
     * @returns {Promise.<number>}
     */
    RegressionEvaluator.prototype.evaluate = function(dataset) {
      var args = {
        target: this,
        method: 'evaluate',
        args: Utils.wrapArguments(arguments),
        returnType: Number
      };

      return Utils.generate(args);
    };

    /**
     * @returns {Promise.<boolean>}
     */
    RegressionEvaluator.prototype.isLargerBetter = function() {
      var args = {
        target: this,
        method: 'isLargerBetter',
        args: Utils.wrapArguments(arguments),
        returnType: Boolean
      };

      return Utils.generate(args);
    };

    /**
     * @param {ParamMap} extra
     * @returns {module:eclairjs/ml/evaluation.RegressionEvaluator}
     */
    RegressionEvaluator.prototype.copy = function(extra) {
      var args = {
        target: this,
        method: 'copy',
        args: Utils.wrapArguments(arguments),
        returnType: RegressionEvaluator
      };

      return Utils.generate(args);
    };

    //
    // static methods
    //

    /**
     * @param {string} path
     * @returns {module:eclairjs/ml/evaluation.RegressionEvaluator}
     */
    RegressionEvaluator.load = function(path) {
      var args = {
        target: RegressionEvaluator,
        method: 'load',
        args: Utils.wrapArguments(arguments),
        static: true,
        kernelP: gKernelP,
        returnType: RegressionEvaluator
      };

      return Utils.generate(args);
    };

    RegressionEvaluator.moduleLocation = '/ml/evaluation/RegressionEvaluator';

    return RegressionEvaluator;
  })();
};