Skip to content

Scoring with MAS

Deva Kumar edited this page Apr 7, 2020 · 2 revisions

Introduction

In this section I discuss how to execute scoring with a model published to MAS using the masSetup and masRun methods of the restaflib library.

masSetup Method

This method sets up the necessary information to score with MAS.

Syntax

let masControl = await restaflib.masSetup(store, models);

The arguments to this method are:

  • store - restaf store
  • models - An array of model names you want to score with

let masControl = await restaflib.masSetup(store, ['model1',...] );

masDescribe method

Use this method to get the input variables

  • masControl - the object returned from masSetup
  • model - name of the model
  • step - the step you are interested in ( defaults to score)

let input = masDescribe(masControl, 'abc', 'xyz);

masRun method

This is the method you will call to score each scenario

Syntax

let result = await restaflib.masRun(store, masControl, modelName,scenario, step);

The parameters to this method are;

  • store - restaf store
  • masControl - the object you got back from casSetup
  • modelName - the name of the model you want to use for scoring. Has to have been specified in the models array to casSetup
  • scenario - a JS object with the input values(see example below)
  • step - this is optional. If not specified the first 'score' in the model will be used for scoring.

Example

async function example () {
  let models = ['sdktgo_iris'];
  let masControl = await restaflib.masSetup(store, models);

  let scenario = {
    petallengthcm: 1.5,
    petalwidthcm : 0.2,
    sepallengthcm: 5,
    sepalwidthcm : 3
  };
  let result = await restaflib.masRun (store, masControl, models[0], scenario);
  console.log(result);

}

A sample result for the model used above is:

{ I_Species               : 'Iris-setosa    ',
  P_SpeciesIris_setosa    : 1,
  P_SpeciesIris_versicolor: 0,
  P_SpeciesIris_virginica : 0,
  _leaf_id_: 2 }

Notes

The methods discussed in this blog use the microanalyticScore REST API

Clone this wiki locally