zModel framework is a predictive model framework built on top of ServiceNow platform. It defines a runtime environment where predictive models can be deployed and used.
Website: https://z-model.com
You build a model outside of ServiceNow using your own machine learning tools and algorithms. Then you use zModel framework to deploy the model into ServiceNow and can use it for any business or IT application and processes.
There are two core entities, which define the framework:
- Model - predictive model, which calculates predictive score based on the input data.
- Score - result of the calculations for the particular model.
The typical use-case for the framework is the following:
- Create / upload the model
- Run the model on the particular input data using internal API, REST API or workflows.
The application can also be downloaded from ServiceNow store
Model defines the logic, which should be used to calculate predictive score for input data.
There are several important fields on the model form:
- Type - type of the model, used for information and verification purposes
- Name - name of the model, can be defined by a user, used for informational purposes only
- Description - description of the model, can be defined by a user, used for informational purposes only
- Logic - the most important field, which defines the model coefficients in the particular format. See the corresponding model documentation for the details about the logic format.
Z Model framework provides three types of the models out of the box:
- Linear Regression
- Logistic Regression (binary classification)
- Softmax Regression (multi class)
Every time when a single score calculated using internal or REST API, Z Model framework creates a record in Score table. Each record contains the following fields:
- Number - record number
- Transaction reference - external transaction reference, can be useful if you need to store external transaction ID
- Model - reference to the model
- User - reference to the user, who runs the transaction
- Status - status of the transaction, 77 - Success, 21 - Error
- Status details - explicit details about the status
- Input - input data
- Score - calculated score / output data
Internal API defined by the script includes, which contains calculation logic for all model types.
var zM = new x_elsr_z_model.zModel(); // initialize Z model object
var input_data = "[1,2,3,4,5]"; // input data in a form of stringify array
var model_sys_id = "98340bf1dbc7f240cc38f7fdbf961957"; // sys_id of the corresponding model
var external_reference = "#AEY90"; // optional parameter - external transaction reference, can be any string up to 40 chars
var result = zM.linearModel(input_data, model_sys_id, external_reference);
// the function returns JSON object with the following properties:
// "status" - status of the transaction
// "status details" - status explanation
// "score" - calculated score
// "score sys_id" - sys_id of the created Score record
Three models provided out of the box:
- Linear model - linear regression model, Score output - stringified JSON matrix with one element type float.
- Logistic model - logistic regression model, Score output - stringified JSON matrix with one element - probability [0..1].
- Softmax model - multi-class logistic regression model, Score output - stringified JSON matrix with probabilities for the corresponding class labels.
// linear model
var lm_result = zM.linearModel(input_data, model_sys_id, external_reference);
// logistic model
var lr_result = zM.logisticModel(input_data, model_sys_id, external_reference);
// softmax model
var sm_result = zM.softmaxModel(input_data, model_sys_id, external_reference);
// initiate new zModel object
var zM = new x_elsr_z_model.zModel();
// input data for a liner regression, 1 - corresponds for a bias
var x = "[96,93,95,1]";
// model sys_id = 98340bf1dbc7f240cc38f7fdbf961957
// external transaction ID = LIN#4735
var result = zM.linearModel(x,"98340bf1dbc7f240cc38f7fdbf961957", "LIN#4735");
gs.log("\n status:"+result.status+"\n status description: "+result['status details']+"\n score: "+result.score+"\n score sys_id: "+result["score sys_id"]);
var zM = new x_elsr_z_model.zModel();
var x = "[1,0,2,1,2,151.55,1]"; // 1 - for the bias
var result = zM.logisticModel(x,"7eb35bf9dbc7f240cc38f7fdbf961948", "LOG#7721");
gs.log("\n\n status:"+result.status+"\n status description: "+result['status details']+"\n score: "+result.score+"\n score sys_id: "+result["score sys_id"]);
var x = "[0.1,0.5,1]"; // 1 - for the bias
var result = zM.softmaxModel(x,"6438137ddbc7f240cc38f7fdbf96195e", "SMX#1217");
gs.log("\n\n status:"+result.status+"\n status description: "+result['status details']+"\n score: "+result.score+"\n score sys_id: "+result["score sys_id"]);
Questions, requests for customization or development services - [email protected]