1
Using ASTORE Models
source link: https://go.documentation.sas.com/doc/en/masag/5.1/n1oajxsgx5pvbrn10bpdufb1axjz.htm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Using ASTORE Models
About ASTORE Models
An Analytic Store, or
ASTORE, is a system that allows the state of a trained predictive
model to be saved in a transportable form. This enables it to subsequently
be used to score new data in a variety of environments. Many SAS
analytical procedures save the results from the training phase of
model development as ASTORE models. A key feature of an ASTORE is
that it can be easily transported from one platform to another. When
an ASTORE is published to SAS Micro Analytic Service, the state of
the predictive model is restored and is available for scoring new
data.
Note: To use ASTORE models, SAS
Event Stream Processing Analytics must be licensed.
Publishing an ASTORE Model
Unlike DS2 and Python
modules, ASTORE models are not published to SAS Micro Analytic Service
as source code. Instead, ASTORE models consist of binary code and
metadata. Client applications deliver ASTORE models to SAS Micro Analytic
Service as disk files.
Note: For information about calling
an ASTORE model by a DS2 module, see
the next section Calling ASTORE Models Using DS2.
Calling ASTORE Models Using DS2
If an ASTORE model has
been registered with SAS Micro Analytic Service, it can be called
by a DS2 module.
Note: For information about publishing
an ASTORE model as a SAS Micro Analytic Service module for direct
execution by calling clients, see the previous
section Publishing an ASTORE Model.
Note: Because of the different
ASTORE configurations that are required by the two execution methods,
a given ASTORE model can be used for direct execution, or for execution
by DS2, but not both at the same time.
A DS2 module that calls
an ASTORE model must include an init() method that invokes the score
package's setvars() and setkey() methods. It must also include the
sc.setOption('_destroyFirstInstLast_', 0) option. This option
makes ASTORE threading compatible with SAS Micro Analytic Service
threading.
Note: Failure to set this option
can cause the system to stop responding on module deletion or on shutdown.
The setvars() method
is used by the DS2 score package to map variables to the ASTORE model's
input and output parameters. The setkey() method takes a SHA-1 hexadecimal
key as input and uses it to look up the ASTORE model.
SAS Micro Analytic Service
automatically calls the init() method, if present, when a DS2 module
is published.
Example
ds2_options sas; package astoretest/overwrite=yes; dcl package score sc(); dcl double CLAGE; dcl double CLNO; dcl double DEBTINC; dcl double DELINQ; dcl double NINQ; dcl double VALUE; dcl double _P_; dcl double P__EVENT_0; dcl double P__EVENT_1; dcl nchar(32) I__EVENT_; dcl nchar(4) _WARN_; varlist allvars [_all_]; method init(); sc.setOption('_destroyFirstInstLast_', 0); sc.setvars(allvars); sc.setkey(n'EB3D1CA20AA0CB74465D25EEE2290E13692AF750'); end; method preCode(); _P_ = 0.999; end; method postCode(); end; method term(); end; method astoreScore(double inCLAGE, double inCLNO, double inDEBTINC, double inDELINQ, double inNINQ, double inVALUE, in_out double out_P_, in_out double outP__EVENT_0, in_out double outP__EVENT_1, in_out nchar outI__EVENT_, in_out nchar out_WARN_); CLAGE = inCLAGE; CLNO = inCLNO; DEBTINC = inDEBTINC; DELINQ = inDELINQ; NINQ = inNINQ; VALUE = inVALUE; preCode(); sc.scoreRecord(); postCode(); out_P_ = _P_; outP__EVENT_0 = P__EVENT_0; outP__EVENT_1 = P__EVENT_1; outI__EVENT_ = I__EVENT_; out_WARN_ = _WARN_; end; endpackage;
Composite Modules
Composite modules enable
DS2 code running in SAS Micro Analytic Service to call one or more
ASTORE models. A composite module consists of one DS2 module and
zero or more ASTORE models, which are known as the members of the
composite. All members of a composite module are published, replaced,
or deleted as a set. For example, if one member of a composite module
fails to publish, then all member of the composite will fail to publish.
Also, any prior revisions of the composite module will remain unchanged.
Like other module types,
the revisions of a composite module are owned by a module context,
have dictionaries, and can be queried for compilation messages, creation
date-times, and so on. The members of a composite module can include
either a DS2 module or an ASTORE model, or both. Other module types,
such as Python and C, are not supported as composite members.
Only the methods of
the DS2 module of the composite are exposed for client applications
to call.
To avoid name collisions
with DS2 modules that exist outside a composite module, each composite
revision has its own namespace. Therefore, each composite module must
be self-contained and without dependencies on any non-member module.
Unlike other module types, composite modules can be called only
externally (for example, driven by SAS Event Stream Processing events
or, in the case of SAS Decision Manager, by web service requests).
In
SAS Event Stream Processing, a composite module is defined by specifying
a DS2 module that calls an ASTORE model or models in the
<mas-module>
tag
and by including the new <module-members>
and <module-member>
sub-tags
of <mas-module>
. Each <module-member>
sub-tag
should specify the location of an ASTORE model on disk. The following
example is an excerpt from an ESP continuous query XML definition:
<mas-modules> <mas-module language="ds2" module="module_1" func-names='astoreScore'> <code-file>/your_ds2_folder/your_astore_caller.ds2</code-file> <module-members> <module-member member='astore_1' SHAkey='EB3D1CA20AA0CB74465D25EEE2290E13692AF750' type='astore'> <code-file>/your_astore_model_folder/your_astore_modelcode-file>/ your_astore_model_folder/your_astore_model> </module-member> </module-members> </mas-module> </mas-modules>
For more information,
see SAS Event Stream Processing: Using SAS Event Stream Processing Studio.
Copyright © SAS Institute Inc. All Rights Reserved.
Last updated: December 4, 2017
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK