Skip to content

Commit 4a3da74

Browse files
committed
Revert "Update sas regression example to use Session.as_swat()"
This reverts commit da592a6.
1 parent da592a6 commit 4a3da74

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

examples/register_sas_regression_model.py

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,37 @@
44
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
55
# SPDX-License-Identifier: Apache-2.0
66

7+
import swat
78
from sasctl import Session
89
from sasctl.tasks import register_model, publish_model
910

10-
hostname = ''
11-
username = ''
12-
password = ''
1311

14-
# Use sasctl to connect to SAS
15-
sess = Session('hostname', 'username', 'password', protocol='http')
16-
cas = sess.as_swat()
12+
with swat.CAS('hostname', 5570, 'username', 'password') as cas:
13+
# Load the regression actions in CAS
14+
cas.loadactionset('regression')
1715

18-
# Load the regression actions in CAS
19-
cas.loadactionset('regression')
16+
# Upload the local CSV file to a CAS table
17+
tbl = cas.upload('data/boston_house_prices.csv').casTable
2018

21-
# Upload the local CSV file to a CAS table
22-
tbl = cas.upload('data/boston_house_prices.csv').casTable
19+
# Model input features are everything except the target
20+
features = tbl.columns[tbl.columns != 'medv']
2321

24-
# Model input features are everything except the target
25-
features = tbl.columns[tbl.columns != 'medv']
22+
# Fit a linear regression model in CAS and output an ASTORE
23+
tbl.glm(target='medv', inputs=list(features), savestate='model_table')
2624

27-
# Fit a linear regression model in CAS and output an ASTORE
28-
tbl.glm(target='medv', inputs=list(features), savestate='model_table')
25+
astore = cas.CASTable('model_table')
2926

30-
astore = cas.CASTable('model_table')
27+
# Use sasctl to connect to SAS
28+
Session('hostname', 'username', 'password')
3129

32-
# Register the model in SAS Model Manager, creating the "Boston Housing"
33-
# project if it doesn't already exist
34-
model = register_model(astore, 'Linear Regression', 'Boston Housing', force=True)
30+
# Register the model in SAS Model Manager, creating the "Boston Housing"
31+
# project if it doesn't already exist
32+
model = register_model(astore, 'Linear Regression', 'Boston Housing', force=True)
3533

36-
# Publish the model to a real-time scoring engine
37-
module = publish_model(model, 'maslocal')
34+
# Publish the model to a real-time scoring engine
35+
module = publish_model(model, 'maslocal')
3836

39-
# Pass a row of data to MAS and receive the predicted result.
40-
first_row = tbl.head(1)
41-
result = module.score(first_row)
42-
print(result)
37+
# Pass a row of data to MAS and receive the predicted result.
38+
first_row = tbl.head(1)
39+
result = module.score(first_row)
40+
print(result)

0 commit comments

Comments
 (0)