Skip to content

Scoring with MAS

devakumaraswamy edited this page Mar 20, 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, ['sdktgo_iris'] );

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 step 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

Setup

Web Applications

Include the following two script tags.

    <script src="https://unpkg.com/@sassoftware/restaf/dist/restaf.min.js"></script>

    <script src="https://unpkg.com/@sassoftware/restaflib/dist/restaflib.min.js"></script>

Two globals restaf and restaflib will be available for use in your script tags.

Nodejs application

Install restaf and restaflib using the following command

    npm install @sassoftware/restaf @sassoftware/restaflib

Clone this wiki locally