BookmarkSubscribeRSS Feed

Building a Model Factory by Using the Automated Machine Learning REST API

Started ‎03-24-2022 by
Modified ‎03-24-2022 by
Views 4,323
Model Studio is a user friendly, low-code visual frontend that allows you to build, automate and operationalize Machine Learning pipelines in a streamlined way, saving time and effort. As a supplement SAS provides a REST API, called Automated Machine Learning in short MLPA, which allows users to automate and industrialize Machine Learning pipelines in batch-mode.

MLPA can be used in two scenarios:

1. Create Machine Learning pipelines automatically, including smart data preparation steps.
2. Run a pre-defined pipeline template on different data segments and different target variables.

In the following blog, I will demonstrate how to automate and industrialize Machine Learning pipelines by using pre-defined pipelines and custom steps in SAS Studio. Within the custom steps I generate code for several REST calls to 
 
  • retrieve a list of available pipeline templates,
  • create automation projects for different data segments,
  • get the status of the automation projects,
  • and get the results from an automation project.

 

But wait! What is a pipeline template? You can build model pipelines in Model Studio and store them to the "Exchange" as a template. For more information see here.

 

Examples

 

1. Retrieve Pipeline Templates

 

filename resp "%substr(&mypath.,11)/resp.json";
proc http 
 method="GET"
 url="https://servername/mlPipelineAutomation/pipelineTemplates?filter=and(eq(modifiedBy,'viyademo01'))"
 ct="application/vnd.sas.collection+json"
 
 oauth_bearer = sas_services
 out=resp; 
run;

libname resp json "%substr(&mypath.,11)/resp.json" map="resp.map" automap=create;

 

2. Create Automation Project

 

Create JSON payload file:
proc json out=filepl pretty;
   write open object;
      write values "dataTableUri" "/dataTables/dataSources/cas~fs~cas-shared-default~fs~Public/tables/&tablename."; 
      write values "type" "predictive"; 
      write values "name" "&targetname."; 
      write values "description" "&targetname. automatic project"; 
      write values "settings";
      write open object;
		  write values "autoRun" &auto.;
          write values "modelingMode" "Standard";           
		  write values "applyGlobalMetadata" &global.; 
          write values "maxModelingTime" 100;           
          write close;           
      write values "pipelineBuildMethod" "template";
      write values "analyticsProjectAttributes";
	  write open object;
          write values "targetVariable" "&targetname.";
          write values "partitionEnabled" true;
          write values "classSelectionStatistic" "&statistic.";             
          write close;
      write values "links";
          write open array;
              write open object;
		          write values "method" "GET";
                  write values "rel" "initialPipelineTemplate";
                  write values "href" "/mlPipelineAutomation/pipelineTemplates/&templateid.";
                  write values "uri" "/mlPipelineAutomation/pipelineTemplates/&templateid.";
				  write values "type" "application/octet-stream";
                  write close; 	
              write close;    
          write close;
    run;
 
Create automation project with payload above:
 
proc http 
 		method="POST"
 		url="https://servername/mlPipelineAutomation/projects"
 		ct="application/vnd.sas.analytics.ml.pipeline.automation.project+json"
 		in=filepl
 		oauth_bearer = sas_services
 		out=model; 
	run;

 

3. Get Project Status

 

proc http 
 method="GET"
 url="https://servername/mlPipelineAutomation/projects?filter=eq(modifiedBy,'viyademo01')"
 ct="application/vnd.sas.collection+json"
 
 oauth_bearer = sas_services
 out=autop; 
run;

 

4. Get Results

 

filename reports "%substr(&mypath.,11)/reports.json";
proc http 
 method="GET"
 url="https://servername/mlPipelineAutomation/projects/f7cacaf3-092b-45d3-9c7a-d72d2ed764b8/models/@championModel/reports"
 ct="application/vnd.sas.collection+json"
 
 oauth_bearer = sas_services
 out=reports; 
run;

libname reports json "%substr(&mypath.,11)/reports.json" map="reports.map" automap=create;
 
The following video shows how the custom steps are used in a SAS Studio flow to create one pipeline per segment of a data set:
 
 

SAS is continuing to enhance Model Studio to be more flexible in areas like multiple target specification, but until those features are released there are also ways you can help yourself here using the MLPA API and custom steps in SAS Studio. So, this is just an example of what can be done with MLPA.

 
More information can be found here:
Version history
Last update:
‎03-24-2022 05:33 AM
Updated by:
Contributors

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Free course: Data Literacy Essentials

Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning  and boost your career prospects.

Get Started

Article Tags