Hi, my name is XiangXiang Meng, Senior Product Manager
for SAS Visual Statistics.
Today, I'm going to share a demonstration
of the Python interface of SAS Visual Statistics
to analyze customer attrition data.
SAS Visual Statistics 8.1 is based on SAS Viya and SAS Cloud
Analytics services.
It provides different programming interface for you
to code underlying CAS analytic actions.
The languages we support include SAS, Python, Lua, Java, as well
RESTful APIs.
Today, I'm going to focus on the Python interface
and demonstrate it the Jupyter Notebook.
Let's take a look.
The Python interface to CAS analytics capabilities
called SWAT, SAS Scripting Wrapper for Analytics Transfer.
Just like using any other Python package,
you first need to import the SWAT package.
In this demonstration, we assume you already
have a running CAS server.
And you have the right authentication
to connect to that server.
Therefore, you only need two pieces of information
to set up a connection from the Python client
to the CAS server, the host name and the port number.
Now we have imported the SWAT package
and set up a connection.
Let's look at what's in the server.
A CAS server contains analytic and non-analytic action sets.
An action set contains one or multiple CAS actions.
We can actually use a CAS action called actionSetInfo
to see which action set has been loaded.
As you can see, these are the action sets
preloaded to your section whenever
you start a new connection.
We can use the help function to get more information.
For example, let's take a look at the simple action set.
Assuming the output simple action set
contains CAS action for basic data exploration and data
summary.
For example, summary statistics, Pearson correlation
coefficient, one way or two way frequency tables, and so forth.
Now, let us move on to the fun part.
Let us analyze some data.
First, we need to know what data sets have
been loaded to this server.
We can actually use the tableInfo action
to take a look.
You can see three tables have been loaded to the server.
Let's focus on the data set called attrition.
This is related to whether customers of a telecom company
want to cancel their subscription or not.
This type of activity is usually called churn or attrition.
To use a CAS table, first you need
to create a reference to that table using the CAS table
method.
Just like, conn as a local reference
to the remote CAS section, data1 is actually
just a local reference to the attrition table in the CAS
server.
We are now moving or downloading the data.
The simple action set provides several useful actions
for data exploration and data summary.
For example, let's get the summary statistics
for all the numeric variables in this data set.
The table displayed here is actually a pandas data frame.
If you've programmed in SAS language before,
you know that the result table from a SAS procedure, SAS
ODS tables.
In this new Python interface, all CAS actions
generate pandas data frame instead.
Therefore, you can work with CAS action results
just like working with pandas dataframe.
For example, you can use caller indexing
to subset the output table.
Given the CAS action results are native dataframe,
you can actually use any other third party
Python packages as long as they support pandas dataframe.
For example, you can use the freq action
to generate a frequency table.
And then use the bokeh package to render a bar
chart to take a look at the customer attrition rate.
Next let's try to build some models.
Logistic regression is one of the models available in SAS
Visual Statistics.
The model is actually in the regression action set.
You need to load the action set before you use the model.
Once the action set is loaded, all the actions
in the action set are automatically
attached to any CAS table object.
For example, you can run a logistic regression model
as the method on the data1 object.
And the minimum set of parameters you need to specify
are the target variables and the predictors.
So far we displayed all the outputs from CAS actions
in the Jupyter HTML format.
The SWAT package also provides a render HTML method
to render the output in a SAS HTML format, which is actually
very similar to the ODS outputs in a SAS environment.
This demo provides an overview of the interface of SAS Visual
Statistics.
We hope you enjoyed it.
Thanks for watching.