Читать книгу SAS Viya - Kevin D. Smith - Страница 26

Working with CAS Action Sets

Оглавление

In the previous sections, we have already seen that a CAS session has access to multiple action sets that each contain multiple actions. However, all of the action sets we have seen so far have been installed automatically when we connect to CAS. We haven’t shown how to load additional action sets in order to do additional operations such as advanced analytics, machine learning, streaming data analysis, and so on.

In order to load new action sets, we must first see what action sets are available on our server. We can use the actionsetinfo action to do that. We are going to use the all=True option to see all of the action sets that are installed on the server rather than only the ones that are currently loaded.

# Run the actionsetinfo action.

In [56]: asinfo = conn.actionsetinfo(all=True)

# Filter the DataFrame to contain only action sets that

# have not been loaded yet.

In [57]: asinfo = asinfo.setinfo[asinfo.setinfo.loaded == 0]

# Create a new DataFrame with only columns between

# actionset and label.

In [58]: asinfo = asinfo.ix[:, 'actionset':'label']

In [59]: asinfo

Out[59]:

Action set information

actionset label

0 access

1 aggregation

2 astore

3 autotune

4 boolRule

5 cardinality

6 clustering

7 decisionTree

… … …

41 svm

42 textMining

43 textParse

44 transpose

45 varReduce

46 casfors Simple forecast service

47 tkcsestst Session Tests

48 cmpcas

59 tkovrd Forecast override

50 qlimreg QLIMREG CAS Action Library

51 panel Panel Data

52 mdchoice MDCHOICE CAS Action Library

53 copula CAS Copula Simulation Action Library

54 optimization Optimization

55 localsearch Local Search Optimization

[56 rows x 2 columns]

Depending on your installation and licensing, the list varies from system to system. One very useful action set that should be automatically available on all systems is the simple action set. This action set contains actions for simple statistics such as summary statistics (max, min, mean, and so on), histograms, correlations, and frequencies. To load an action set, use the loadactionset action:

In [60]: conn.loadactionset('simple')

NOTE: Added action set 'simple'.

Out[60]:

[actionset]

'simple

+ Elapsed: 0.0175s, user: 0.017s, mem: 0.255mb

As you can see, this action returns a CASResults object as described in the previous section. It contains a single key called actionset that contains the name of the action set that was loaded. Typically, you do not need this return value, but it can be used to verify that the action set has been loaded. If you attempt to load an action set that cannot be loaded for some reason (such as incorrect name, no license, or no authorization), the CASResults object is empty.

Now that we have loaded the simple action set, we can get help on it using the usual Python methods.

In [61]: conn.simple?

Type: Simple

String form: <swat.cas.actions.Simple object at 0x7f3cdf7c07f0>

File: swat/cas/actions.py

Docstring:

Analytics

Actions

-------

simple.correlation : Generates a matrix of Pearson product-moment

correlation coefficients

simple.crosstab : Performs one-way or two-way tabulations

simple.distinct : Computes the distinct number of values of the

variables in the variable list

simple.freq : Generates a frequency distribution for one or

more variables

simple.groupby : Builds BY groups in terms of the variable value

combinations given the variables in the variable

list

simple.mdsummary : Calculates multidimensional summaries of numeric

variables

simple.numrows : Shows the number of rows in a Cloud Analytic

Services table

simple.paracoord : Generates a parallel coordinates plot of the

variables in the variable list

simple.regression : Performs a linear regression up to 3rd-order

polynomials

simple.summary : Generates descriptive statistics of numeric

variables such as the sample mean, sample

variance, sample size, sum of squares, and so on

simple.topk : Returns the top-K and bottom-K distinct values of

each variable included in the variable list based

on a user-specified ranking order

Once an action set has been loaded, it cannot be unloaded. The overhead for keeping an action set loaded is minimal, so this issue doesn’t make a significant difference.

That is really all there is to loading action sets. We still do not have data in our system, so we cannot use any of the simple statistics actions yet. Let’s review some final details about options and dealing with errors in the next section, then the following chapter gets into the ways of loading data and using the analytical actions on those data sets.

SAS Viya

Подняться наверх