Name

sn_rf.RFClassificationService

Description

No description available

Script

var RFClassificationService = Class.create();
RFClassificationService.prototype = {
  tableName: RFConstants.tables.ML_CAPABILITY_DEFINITION_CLASSIFICATION,

  initialize: function(grOrSysId) {
      if (grOrSysId && grOrSysId.sys_class_name == this.tableName && grOrSysId.isValidRecord()) {
          this.currentRecord = grOrSysId;
      } else {
          var solutionDefGr = new GlideRecord(this.tableName);
          if (solutionDefGr.get(grOrSysId)) {
              this.currentRecord = solutionDefGr;
          }
      }
  },

  hasValidRecord: function() {
      return Boolean(this.currentRecord);
  },

  getPredictions: function(current, additionalParameters) {
      var predictions = [];
      if (!this.hasValidRecord()) {
          return predictions;
      }
      var predictor = new global.MLPredictor();
      var solution = predictor.findActiveSolution(this.getSolutionName());
      if (solution && predictor.isClassificationSolution(solution)) {
          var options = {};
          if (additionalParameters && additionalParameters[RFConstants.mlPredictorOptions.TOP_N]) {
              options[RFConstants.mlPredictorOptions.TOP_N] = additionalParameters[RFConstants.mlPredictorOptions.TOP_N];
          }
          predictions = predictor.getPredictions(current, solution, options);
      }
      return predictions;
  },

  getTable: function() {
      return this.currentRecord.getValue(RFConstants.fields.ML_CAPABILITY_DEFINITION_BASE_TABLE);
  },

  getOutputField: function() {
      return this.currentRecord.getValue(RFConstants.fields.ML_CAPABILITY_DEFINITION_CLASSIFICATION_OUTPUT_FIELD);
  },

  getSolutionName: function() {
      return this.currentRecord.getValue(RFConstants.fields.ML_CAPABILITY_DEFINITION_BASE_SOLUTION_NAME);
  },

  getOutputFieldType: function() {
      var tableGR = new GlideRecord(this.getTable());
      if (tableGR.isValid()) {
          var field = tableGR.getElement(this.getOutputField());
          if (field != null) {
              return field.getED().getInternalType();
          }
      }
  },

  getOutputFieldReferenceTable: function() {
      return RFUtils.getFieldReferenceTable(this.getTable(), this.getOutputField());
  },

  type: 'RFClassificationService'
};

Sys ID

63088139530330107234ddeeff7b1264

Offical Documentation

Official Docs: