JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q34945F
  • License MIT

npm module for openscoring REST API

Package Exports

  • openscoring

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (openscoring) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

openscoring - Simple API for openscoring REST interface

openscoring is designed to be a simple way to make calls to an openscoring server. For making the XMLHttpRequest to openscoring, this module uses the request module which supports both HTTP and HTTPS.

All methods return a Promise and should be used as follows:

var openscoring = require('openscoring');
var result = openscoring.summary();
result.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

Table of Contents

Note: Plan to add the ability to deploy and delete models at some point. CSV evaluate support not currently implemented.

Installation

npm install --save openscoring

setURL

This method sets the URL for the OpenScoring server. This should include the full path of the default URL, for example:

openscoring.setURL("http://localhost:8080/openscoring");

back to top

getURL

Returns the current URL endpoint for the OpenScoring server.

openscoring.getURL("http://localhost:8080/openscoring");

back to top

evaluate

This method evaluates a single or batch set of data against a given data model, depending on the structure of the data that is passed.

Returns a Promise

Note: the data parameter must be a jsonobject in the format expected by openscoring (see openscoring GitHub page for full details)

Example: Single data set

openscoring.setURL("http://localhost:8080/openscoring");
var data = {
"id": "record-001",
"arguments": {
    "item1": 2345,
    "item2": 3345,
    "item3": 53,
    }
};
var result = openscoring.evaluate("model", data);
result.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

For batch mode, the data looks for a key called requests per the openscoring documentation:

Example: Batch data set

openscoring.setURL("http://localhost:8080/openscoring");
var data = {
    "id" : "batch-1",
    "requests" : [
        {
        "id": "record-001",
        "arguments": {
            "item1": 1,
            "item2": 1,
            "item3": 1,
            }
        },
        {
        "id": "record-002",
        "arguments": {
            "item1": 10,
            "item2": 10,
            "item3": 10,
            }
        }	
    ]
};

var result = openscoring.evaluate("model", data);
result.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

back to top

metric

Retrieves model metrics for one or all deployed models depending on whether the model parameter is passed.

This action equires administrative rights on the openscoring server. See openscoring documentation for details.

openscoring.metric(model)
// or
openscoring.metric()

Example

openscoring.setURL("http://localhost:8080/openscoring");
var result = openscoring.metric();
result.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

back to top

pmml

Retrieves the PMML for a given model. Requires administrative rights on the openscoring server. See openscoring documentation for details.

Example

openscoring.setURL("http://localhost:8080/openscoring");
var result = openscoring.pmml("model");
result.then((result) => {
    console.log(result);
}).catch((error) => {
    console.warn(error);
});

back to top