ibm-research/WatsonxDocsQARetrieval huggingface dataset:
# SuperNode flows #

A SuperNode flow is the type of flow used within a SuperNode\. Like a normal flow, it contains nodes that are linked together\. SuperNode flows differ from normal flows in various ways:

<!-- <ul> -->

 *  Parameters and any scripts are associated with the SuperNode that owns the SuperNode flow, rather than with the SuperNode flow itself\.
 *  SuperNode flows have additional input and output connector nodes, depending on the type of SuperNode\. These connector nodes are used to push information into and out of the SuperNode flow, and are created automatically when the SuperNode is created\.

<!-- </ul> -->

<!-- </article "role="article" "> -->
# Using non\-ASCII characters #

To use non\-ASCII characters, Python requires explicit encoding and decoding of strings into Unicode\. In  SPSS Modeler, Python scripts are assumed to be encoded in UTF\-8, which is a standard Unicode encoding that supports non\-ASCII characters\. The following script will compile because the Python compiler has been set to UTF\-8 by  SPSS Modeler\.

![Scripting example showing Japanese characters\. The node that's created has an incorrect label\.](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/jython/clementine/images/japanese_example1.jpg)

However, the resulting node has an incorrect label\.

Figure 1\. Node label containing non\-ASCII characters, displayed incorrectly

![Node label containing non\-ASCII characters, displayed incorrectly](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/jython/clementine/images/incorrect_node_label.jpg)

The label is incorrect because the string literal itself has been converted to an ASCII string by Python\.

Python allows Unicode string literals to be specified by adding a `u` character prefix before the string literal:

![Scripting example showing Japanese characters\. The node that's created has the correct label\.](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/jython/clementine/images/japanese_example2.jpg)

This will create a Unicode string and the label will be appear correctly\.

Figure 2\. Node label containing non\-ASCII characters, displayed correctly

![Node label containing non\-ASCII characters, displayed correctly](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/jython/clementine/images/correct_node_label.jpg)

Using Python and Unicode is a large topic that's beyond the scope of this document\. Many books and online resources are available that cover this topic in great detail\.

<!-- </article "role="article" "> -->
# Blocks of code #

Blocks of code are groups of statements you can use where single statements are expected\.

Blocks of code can follow any of the following statements: `if`, `elif`, `else`, `for`, `while`, `try`, `except`, `def`, and `class`\. These statements introduce the block of code with the colon character (`:`)\. For example:

    if x == 1: 
        y = 2
        z = 3
    elif:
        y = 4
        z = 5

Use indentation to delimit code blocks (rather than the curly braces used in Java)\. All lines in a block must be indented to the same position\. This is because a change in the indentation indicates the end of a code block\. It's common to indent by four spaces per level\. We recommend you use spaces to indent the lines, rather than tabs\. Spaces and tabs must not be mixed\. The lines in the outermost block of a module must start at column one, or a SyntaxError will occur\.

The statements that make up a code block (and follow the colon) can also be on a single line, separated by semicolons\. For example:

    if x == 1: y = 2; z = 3;

<!-- </article "role="article" "> -->
# Examples #

The `print` keyword prints the arguments immediately following it\. If the statement is followed by a comma, a new line isn't included in the output\. For example:

    print "This demonstrates the use of a",
    print " comma at the end of a print statement."

This will result in the following output:

    This demonstrates the use of a comma at the end of a print statement.

The `for` statement iterates through a block of code\. For example:

    mylist1 = ["one", "two", "three"]
    for lv in mylist1:
        print lv
        continue

In this example, three strings are assigned to the list `mylist1`\. The elements of the list are then printed, with one element of each line\. This results in the following output:

    one
    two
    three

In this example, the iterator `lv` takes the value of each element in the list `mylist1` in turn as the `for` loop implements the code block for each element\. An iterator can be any valid identifier of any length\.

The `if` statement is a conditional statement\. It evaluates the condition and returns either true or false, depending on the result of the evaluation\. For example:

    mylist1 = ["one", "two", "three"]
    for lv in mylist1:
        if lv == "two"
            print "The value of lv is ", lv
        else
            print "The value of lv is not two, but ", lv
        continue

In this example, the value of the iterator `lv` is evaluated\. If the value of `lv` is `two`, a different string is returned to the string that's returned if the value of `lv` is not `two`\. This results in the following output:

    The value of lv is not two, but one
    The value of lv is two
    The value of lv is not two, but three

<!-- </article "role="article" "> -->
# Identifiers #

Identifiers are used to name variables, functions, classes, and keywords\.

Identifiers can be any length, but must start with either an alphabetical character of uppercase or lowercase, or the underscore character (`_`)\. Names that start with an underscore are generally reserved for internal or private names\. After the first character, the identifier can contain any number and combination of alphabetical characters, numbers from 0\-9, and the underscore character\.

There are some reserved words in Jython that can't be used to name variables, functions, or classes\. They fall under the following categories:

<!-- <ul> -->

 *  Statement introducers:`assert`, `break`, `class`, `continue`, `def`, `del`, `elif`, `else`, `except`, `exec`, `finally`, `for`, `from`, `global`, `if`, `import`, `pass`, `print`, `raise`, `return`, `try`, and `while`
 *  Parameter introducers:`as`, `import`, and `in`
 *  Operators:`and`, `in`, `is`, `lambda`, `not`, and `or`

<!-- </ul> -->

Improper keyword use generally results in a SyntaxError\.

<!-- </article "role="article" "> -->
# Operations #

Use an equals sign (`=`) to assign values\.

For example, to assign the value `3` to a variable called `x`, you would use the following statement:

    x = 3

You can also use the equals sign to assign string type data to a variable\. For example, to assign the value `a string value` to the variable `y`, you would use the following statement:

    y = "a string value"

The following table lists some commonly used comparison and numeric operations, and their descriptions\.

<!-- <table "summary="Common comparison and numeric operations" class="defaultstyle" "> -->

Common comparison and numeric operations  

Table 1\. Common comparison and numeric operations

| Operation      | Description                          |
| -------------- | ------------------------------------ |
| `x < y`     | Is `x` less than `y`?                |
| `x > y`     | Is `x` greater than `y`?             |
| `x <= y`    | Is `x` less than or equal to `y`?    |
| `x >= y`    | Is `x` greater than or equal to `y`? |
| `x == y`       | Is `x` equal to `y`?                 |
| `x != y`       | Is `x` not equal to `y`?             |
| `x <> y` | Is `x` not equal to `y`?             |
| `x + y`        | Add `y` to `x`                       |
| `x - y`        | Subtract `y` from `x`                |
| `x * y`        | Multiply `x` by `y`                  |
| `x / y`        | Divide `x` by `y`                    |
| `x ** y`       | Raise `x` to the `y` power           |

<!-- </table "summary="Common comparison and numeric operations" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# Passing arguments to a script #

Passing arguments to a script is useful because a script can be used repeatedly without modification\.

The arguments you pass on the command line are passed as values in the list `sys.argv`\. You can use the `len(sys.argv)` command to obtain the number of values passed\. For example:

    import sys
    print "test1"
    print sys.argv[0]
    print sys.argv[1]
    print len(sys.argv)

In this example, the `import` command imports the entire `sys` class so that you can use the existing methods for this class, such as `argv`\.

The script in this example can be invoked using the following line:

    /u/mjloos/test1 mike don

The result is the following output:

    /u/mjloos/test1 mike don
    test1
    mike
    don
    3

<!-- </article "role="article" "> -->
# Remarks #

Remarks are comments that are introduced by the pound (or hash) sign (`#`)\. All text that follows the pound sign on the same line is considered part of the remark and is ignored\. A remark can start in any column\.

The following example demonstrates the use of remarks:

    #The HelloWorld application is one of the most simple
    print 'Hello World' # print the Hello World line

<!-- </article "role="article" "> -->
# Statement syntax #

The statement syntax for Python is very simple\.

In general, each source line is a single statement\. Except for `expression` and `assignment` statements, each statement is introduced by a keyword name, such as `if` or `for`\. Blank lines or remark lines can be inserted anywhere between any statements in the code\. If there's more than one statement on a line, each statement must be separated by a semicolon (`;`)\.

Very long statements can continue on more than one line\. In this case, the statement that is to continue on to the next line must end with a backslash (`\`)\. For example:

    x = "A loooooooooooooooooooong string" + \
         "another looooooooooooooooooong string"

When you enclose a structure by parentheses (`()`), brackets (`[]`), or curly braces (`{}`), the statement can be continued on a new line after any comma, without having to insert a backslash\. For example:

    x = (1, 2, 3, "hello",
          "goodbye", 4, 5, 6)

<!-- </article "role="article" "> -->
# Strings #

A string is an immutable sequence of characters that's treated as a value\. Strings support all of the immutable sequence functions and operators that result in a new string\. For example, `"abcdef"[1:4]` results in the output `"bcd"`\.

In Python, characters are represented by strings of length one\.

Strings literals are defined by the use of single or triple quoting\. Strings that are defined using single quotes can't span lines, while strings that are defined using triple quotes can\. You can enclose a string in single quotes (`'`) or double quotes (`"`)\. A quoting character may contain the other quoting character un\-escaped or the quoting character escaped, that's preceded by the backslash (`\`) character\.

<!-- </article "role="article" "> -->
# kdeapply properties #

You can use the KDE Modeling node to generate a KDE model nugget\. The scripting name of this model nugget is `kdeapply`\. For information on scripting the modeling node itself, see [kdemodel properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/kdemodelnodeslots.html#kdemodelnodeslots)\.

<!-- <table "summary="kdeapply properties" id="kdenuggetnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

kdeapply properties  

Table 1\. kdeapply properties

| `kdeapply` properties | Data type | Property description                                                                                       |
| --------------------- | --------- | ---------------------------------------------------------------------------------------------------------- |
| `out_log_density`     | *boolean* | Specify `True` or `False` to include or exclude the log density value in the output\. Default is `False`\. |

<!-- </table "summary="kdeapply properties" id="kdenuggetnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applykmeansnode properties #

You can use K\-Means modeling nodes to generate a K\-Means model nugget\. The scripting name of this model nugget is *applykmeansnode*\. No other properties exist for this model nugget\. For more information on scripting the modeling node itself, see [kmeansnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/kmeansnodeslots.html#kmeansnodeslots)\.

<!-- </article "role="article" "> -->
# applyknnnode properties #

You can use KNN modeling nodes to generate a KNN model nugget\. The scripting name of this model nugget is *applyknnnode*\. For more information on scripting the modeling node itself, see [knnnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/knnnodeslots.html#knnnodeslots)\.

<!-- <table "summary="applyknnnode properties" id="knnnuggetnodeslots__table_e5c_bdj_cdb" class="defaultstyle" "> -->

applyknnnode properties  

Table 1\. applyknnnode properties

| `applyknnnode` Properties | Values          | Property description                                                                                                                             |
| ------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `all_probabilities`       | *flag*          |                                                                                                                                                  |
| `save_distances`          | *flag*          |                                                                                                                                                  |
| `enable_sql_generation`   | `false``native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applyknnnode properties" id="knnnuggetnodeslots__table_e5c_bdj_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applykohonennode properties #

You can use Kohonen modeling nodes to generate a Kohonen model nugget\. The scripting name of this model nugget is *applykohonennode*\. For more information on scripting the modeling node itself, see [c50node properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/c50nodeslots.html#c50nodeslots)\.

<!-- <table "summary="applykohonennode properties" id="kohonennuggetnodeslots__table_vcl_gbj_cdb" class="defaultstyle" "> -->

applykohonennode properties  

Table 1\. applykohonennode properties

| `applykohonennode` Properties | Values                | Property description                                                                                                                             |
| ----------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enable_sql_generation`       | `false``true``native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applykohonennode properties" id="kohonennuggetnodeslots__table_vcl_gbj_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applylogregnode properties #

You can use Logistic modeling nodes to generate a Logistic model nugget\. The scripting name of this model nugget is *applylogregnode*\. For more information on scripting the modeling node itself, [logregnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/logregnodeslots.html#logregnodeslots)\.

<!-- <table "summary="applylogregnode properties" id="logregnuggetnodeslots__table_s2w_gdj_cdb" class="defaultstyle" "> -->

applylogregnode properties  

Table 1\. applylogregnode properties

| `applylogregnode` Properties | Values | Property description |
| ---------------------------- | ------ | -------------------- |
| `calculate_raw_propensities` | *flag* |                      |
| `calculate_conf`             | *flag* |                      |
| `enable_sql_generation`      | *flag* |                      |

<!-- </table "summary="applylogregnode properties" id="logregnuggetnodeslots__table_s2w_gdj_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applylsvmnode properties #

You can use LSVM modeling nodes to generate an LSVM model nugget\. The scripting name of this model nugget is *applylsvmnode*\. For more information on scripting the modeling node itself, see [lsvmnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/lsvmnodeslots.html)\.

<!-- <table "summary="applylsvmnode properties" class="defaultstyle" "> -->

applylsvmnode properties  

Table 1\. applylsvmnode properties

| `applylsvmnode` Properties   | Values          | Property description                                                                                                                             |
| ---------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `calculate_raw_propensities` | *flag*          | Specifies whether to calculate raw propensity scores\.                                                                                           |
| `enable_sql_generation`      | `false``native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applylsvmnode properties" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyocsvmnode properties #

You can use One\-Class SVM nodes to generate a One\-Class SVM model nugget\. The scripting name of this model nugget is *applyocsvmnode*\. No other properties exist for this model nugget\. For more information on scripting the modeling node itself, see [ocsvmnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/oneclasssvmnodeslots.html#oneclasssvmnodeslots)\.

<!-- </article "role="article" "> -->
# applylinearasnode properties #

You can use Linear\-AS modeling nodes to generate a Linear\-AS model nugget\. The scripting name of this model nugget is *applylinearasnode*\. For more information on scripting the modeling node itself, see [linearasnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/properties/linearASslots.html#linearASslots)\.

<!-- <table "summary="applylinearasnode Properties" class="defaultstyle" "> -->

applylinearasnode Properties  

Table 1\. applylinearasnode Properties

| `applylinearasnode` Property | Values          | Property description                                                                                                                             |
| ---------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `enable_sql_generation`      | `false``native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applylinearasnode Properties" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applylinearnode properties #

Linear modeling nodes can be used to generate a Linear model nugget\. The scripting name of this model nugget is *applylinearnode*\. For more information on scripting the modeling node itself, see [linearnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/properties/linearslots.html#linearslots)\.

<!-- <table "summary="applylinearnode Properties" id="applylinearslots__table_w2c_hj3_cdb" class="defaultstyle" "> -->

applylinearnode Properties  

Table 1\. applylinearnode Properties

| `linear` Properties     | Values                 | Property description                                                                                                                                                                                                                                                                                                                           |
| ----------------------- | ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `use_custom_name`       | *flag*                 |                                                                                                                                                                                                                                                                                                                                                |
| `custom_name`           | *string*               |                                                                                                                                                                                                                                                                                                                                                |
| `enable_sql_generation` | `udf``native``puresql` | Used to set SQL generation options during flow execution\. The options are to push back to the database and score using an SPSS Modeler Server scoring adapter (if connected to a database with a scoring adapter installed), to score within SPSS Modeler, or to push back to the database and score using SQL\. The default value is `udf`\. |

<!-- </table "summary="applylinearnode Properties" id="applylinearslots__table_w2c_hj3_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyneuralnetworknode properties #

You can use Neural Network modeling nodes to generate a Neural Network model nugget\. The scripting name of this model nugget is *applyneuralnetworknode*\. For more information on scripting the modeling node itself, see [neuralnetworknode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/properties/neuralnetworkslots.html#neuralnetworkslots)\.

<!-- <table "summary="applyneuralnetworknode properties" id="applyneuralnetworkslots__table_x3s_3j3_cdb" class="defaultstyle" "> -->

applyneuralnetworknode properties  

Table 1\. applyneuralnetworknode properties

| `applyneuralnetworknode` Properties | Values                            | Property description                                                                                                                             |
| ----------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `use_custom_name`                   | *flag*                            |                                                                                                                                                  |
| `custom_name`                       | *string*                          |                                                                                                                                                  |
| `confidence`                        | `onProbability`  <br>`onIncrease` |                                                                                                                                                  |
| `score_category_probabilities`      | *flag*                            |                                                                                                                                                  |
| `max_categories`                    | *number*                          |                                                                                                                                                  |
| `score_propensity`                  | *flag*                            |                                                                                                                                                  |
| `enable_sql_generation`             | `false`  <br>`true`  <br>`native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applyneuralnetworknode properties" id="applyneuralnetworkslots__table_x3s_3j3_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyquestnode properties #

You can use QUEST modeling nodes can be used to generate a QUEST model nugget\. The scripting name of this model nugget is *applyquestnode*\. For more information on scripting the modeling node itself, see [questnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/questnodeslots.html)\.

<!-- <table "summary="applyquestnode properties" id="questnuggetnodeslots__table_wcx_d2j_cdb" class="defaultstyle" "> -->

applyquestnode properties  

Table 1\. applyquestnode properties

| `applyquestnode` Properties       | Values                                                            | Property description                                                                                                                             |
| --------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `sql_generate`                    | `Never`  <br>`NoMissingValues`  <br>`MissingValues`  <br>`native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |
| `calculate_conf`                  | *flag*                                                            |                                                                                                                                                  |
| `display_rule_id`                 | *flag*                                                            | Adds a field in the scoring output that indicates the ID for the terminal node to which each record is assigned\.                                |
| `calculate_raw_propensities`      | *flag*                                                            |                                                                                                                                                  |
| `calculate_adjusted_propensities` | *flag*                                                            |                                                                                                                                                  |

<!-- </table "summary="applyquestnode properties" id="questnuggetnodeslots__table_wcx_d2j_cdb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyregressionnode properties #

You can use Linear Regression modeling nodes to generate a Linear Regression model nugget\. The scripting name of this model nugget is *applyregressionnode*\. No other properties exist for this model nugget\. For more information on scripting the modeling node itself, see [regressionnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/regressionnodeslots.html#regressionnodeslots)\.

<!-- </article "role="article" "> -->
# reordernode properties #

![Field Reorder node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/fieldreordernodeicon.png)The Field Reorder node defines the natural order used to display fields downstream\. This order affects the display of fields in a variety of places, such as tables, lists, and when selecting fields\. This operation is useful when working with wide datasets to make fields of interest more visible\.

<!-- <table "summary="reordernode properties" class="defaultstyle" "> -->

reordernode properties  

Table 1\. reordernode properties

| `reordernode` properties | Data type                    | Property description                                          |
| ------------------------ | ---------------------------- | ------------------------------------------------------------- |
| `mode`                   | `Custom``Auto`               | You can sort values automatically or specify a custom order\. |
| `sort_by`                | `Name``Type``Storage`        |                                                               |
| `ascending`              | *flag*                       |                                                               |
| `start_fields`           | *\[field1 field2 … fieldn\]* | New fields are inserted after these fields\.                  |
| `end_fields`             | *\[field1 field2 … fieldn\]* | New fields are inserted before these fields\.                 |

<!-- </table "summary="reordernode properties" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# restructurenode properties #

![Restructure node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/restructurenodeicon.png)The Restructure node converts a nominal or flag field into a group of fields that can be populated with the values of yet another field\. For example, given a field named `payment type`, with values of `credit`, `cash`, and `debit`, three new fields would be created (`credit`, `cash`, `debit`), each of which might contain the value of the actual payment made\.

Example

    node = stream.create("restructure", "My node")
    node.setKeyedPropertyValue("fields_from", "Drug", ["drugA", "drugX"])
    node.setPropertyValue("include_field_name", True)
    node.setPropertyValue("value_mode", "OtherFields")
    node.setPropertyValue("value_fields", ["Age", "BP"])

<!-- <table "summary="restructurenode properties" id="restructurenodeslots__table_er4_5vs_ddb" class="defaultstyle" "> -->

restructurenode properties  

Table 1\. restructurenode properties

| `restructurenode` properties | Data type                              | Property description                                                                                                                                                               |
| ---------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `fields_from`                | \[*category category category*\] `all` |                                                                                                                                                                                    |
| `include_field_name`         | *flag*                                 | Indicates whether to use the field name in the restructured field name\.                                                                                                           |
| `value_mode`                 | `OtherFields``Flags`                   | Indicates the mode for specifying the values for the restructured fields\. With `OtherFields`, you must specify which fields to use\. With `Flags`, the values are numeric flags\. |
| `value_fields`               | *list*                                 | Required if `value_mode` is `OtherFields`\. Specifies which fields to use as value fields\.                                                                                        |

<!-- </table "summary="restructurenode properties" id="restructurenodeslots__table_er4_5vs_ddb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyrandomtrees properties #

You can use the Random Trees modeling node to generate a Random Trees model nugget\. The scripting name of this model nugget is *applyrandomtrees*\. For more information on scripting the modeling node itself, see [randomtrees properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/rf_nodeslots.html#rf_nodeslots)\.

<!-- <table "summary="applyrandomtrees properties" class="defaultstyle" "> -->

applyrandomtrees properties  

Table 1\. applyrandomtrees properties

| `applyrandomtrees` Properties | Values                | Property description                                                                                                                             |
| ----------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `calculate_conf`              | *flag*                | This property includes confidence calculations in the generated tree\.                                                                           |
| `enable_sql_generation`       | `false`  <br>`native` | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applyrandomtrees properties" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# Running and interrupting scripts #

You can run scripts in a number of ways\. For example, in the flow script or standalone script pane, click  Run This Script to run the complete script\.

You can run a script using any of the following methods:

<!-- <ul> -->

 *  Click  Run script within a flow script or standalone script\.
 *  Run a flow where  Run script is set as the default execution method\.

<!-- </ul> -->

Note: A SuperNode script runs when the SuperNode is run as long as you select  Run script within the SuperNode script dialog box\.
<!-- </article "role="article" "> -->
# Accessing flow run results #

Many SPSS Modeler nodes produce output objects such as models, charts, and tabular data\. Many of these outputs contain useful values that can be used by scripts to guide subsequent runs\. These values are grouped into content containers (referred to as simply containers) which can be accessed using tags or IDs that identify each container\. The way these values are accessed depends on the format or "content model" used by that container\.

For example, many predictive model outputs use a variant of XML called PMML to represent information about the model such as which fields a decision tree uses at each split, or how the neurons in a neural network are connected and with what strengths\. Model outputs that use PMML provide an XML Content Model that can be used to access that information\. For example:

    stream = modeler.script.stream()
    # Assume the flow contains a single C5.0 model builder node
    # and that the datasource, predictors, and targets have already been
    # set up
    modelbuilder = stream.findByType("c50", None)
    results = []
    modelbuilder.run(results)
    modeloutput = results[0]
    
    # Now that we have the C5.0 model output object, access the
    # relevant content model
    cm = modeloutput.getContentModel("PMML")
    
    # The PMML content model is a generic XML-based content model that
    # uses XPath syntax. Use that to find the names of the data fields.
    # The call returns a list of strings match the XPath values
    dataFieldNames = cm.getStringValues("/PMML/DataDictionary/DataField", "name")

SPSS Modeler supports the following content models in scripting:

<!-- <ul> -->

 *  Table content model provides access to the simple tabular data represented as rows and columns\.
 *  XML content model provides access to content stored in XML format\.
 *  JSON content model provides access to content stored in JSON format\.
 *  Column statistics content model provides access to summary statistics about a specific field\.
 *  Pair\-wise column statistics content model provides access to summary statistics between two fields or values between two separate fields\.

<!-- </ul> -->

Note that the following nodes don't contain these content models:

<!-- <ul> -->

 *  Time Series
 *  Discriminant
 *  SLRM
 *  All Extension nodes
 *  All Database Modeling nodes

<!-- </ul> -->

<!-- </article "role="article" "> -->
# Looping through nodes #

You can use a `for` loop to loop through all the nodes in a flow\. For example, the following two script examples loop through all nodes and change field names in any Filter nodes to uppercase\.

You can use this script in any flow that contains a Filter node, even if no fields are actually filtered\. Simply add a Filter node that passes all fields in order to change field names to uppercase across the board\.

    # Alternative 1: using the data model nameIterator() function
    stream = modeler.script.stream()
    for node in stream.iterator():
        if (node.getTypeName() == "filter"):
            # nameIterator() returns the field names
            for field in node.getInputDataModel().nameIterator():
                newname = field.upper()
                node.setKeyedPropertyValue("new_name", field, newname)

    # Alternative 2: using the data model iterator() function
    stream = modeler.script.stream()
    for node in stream.iterator():
        if (node.getTypeName() == "filter"):
            # iterator() returns the field objects so we need
            # to call getColumnName() to get the name
            for field in node.getInputDataModel().iterator():
                newname = field.getColumnName().upper()
                node.setKeyedPropertyValue("new_name", field.getColumnName(), newname)

The script loops through all nodes in the current flow, and checks whether each node is a Filter\. If so, the script loops through each field in the node and uses either the `field.upper()` or `field.getColumnName().upper()` function to change the name to uppercase\.

<!-- </article "role="article" "> -->
# Scripting and automation #

Scripting in SPSS Modeler is a powerful tool for automating processes in the user interface\. Scripts can perform the same types of actions that you perform with a mouse or a keyboard, and you can use them to automate tasks that would be highly repetitive or time consuming to perform manually\.

You can use scripts to:

<!-- <ul> -->

 *  Impose a specific order for node executions in a flow\.
 *  Set properties for a node as well as perform derivations using a subset of CLEM (Control Language for Expression Manipulation)\.
 *  Specify an automatic sequence of actions that normally involves user interaction—for example, you can build a model and then test it\.
 *  Set up complex processes that require substantial user interaction—for example, cross\-validation procedures that require repeated model generation and testing\.
 *  Set up processes that manipulate flows—for example, you can take a model training flow, run it, and produce the corresponding model\-testing flow automatically\.

<!-- </ul> -->

<!-- </article "role="article" "> -->
# Types of scripts #

SPSS Modeler uses three types of scripts:

<!-- <ul> -->

 *  Flow scripts are stored as a flow property and are therefore saved and loaded with a specific flow\. For example, you can write a flow script that automates the process of training and applying a model nugget\. You can also specify that whenever a particular flow runs, the script should be run instead of the flow's canvas content\.
 *  Standalone scripts aren't associated with any particular flow and are saved in external text files\. You might use a standalone script, for example, to manipulate multiple flows together\.
 *  SuperNode scripts are stored as a SuperNode flow property\. SuperNode scripts are only available in terminal SuperNodes\. You might use a SuperNode script to control the execution sequence of the SuperNode contents\. For nonterminal (import or process) SuperNodes, you can define properties for the SuperNode or the nodes it contains in your flow script directly\.

<!-- </ul> -->

<!-- </article "role="article" "> -->
# selectnode properties #

![Select node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/select_node_icon.png) The Select node selects or discards a subset of records from the data stream based on a specific condition\. For example, you might select the records that pertain to a particular sales region\.

<!-- <table "summary="selectnode properties" id="selectnodeslots__table_ucw_bwy_ddb" class="defaultstyle" "> -->

selectnode properties  

Table 1\. selectnode properties

| `selectnode` properties | Data type          | Property description                                       |
| ----------------------- | ------------------ | ---------------------------------------------------------- |
| `mode`                  | `Include``Discard` | Specifies whether to include or discard selected records\. |
| `condition`             | *string*           | Condition for including or discarding records\.            |

<!-- </table "summary="selectnode properties" id="selectnodeslots__table_ucw_bwy_ddb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applyselflearningnode properties #

You can use Self\-Learning Response Model (SLRM) modeling nodes to generate a SLRM model nugget\. The scripting name of this model nugget is *applyselflearningnode*\. For more information on scripting the modeling node itself, see [slrmnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/selflearnnodeslots.html#selflearnnodeslots)\.

<!-- <table "summary="applyselflearningnode properties" id="selflearnnuggetnodeslots__table_czt_2wy_ddb" class="defaultstyle" "> -->

applyselflearningnode properties  

Table 1\. applyselflearningnode properties

| `applyselflearningnode` Properties | Values                        | Property description                                                                                                                             |
| ---------------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `max_predictions`                  | *number*                      |                                                                                                                                                  |
| `randomization`                    | *number*                      |                                                                                                                                                  |
| `scoring_random_seed`              | *number*                      |                                                                                                                                                  |
| `sort`                             | `ascending`  <br>`descending` | Specifies whether the offers with the highest or lowest scores will be displayed first\.                                                         |
| `model_reliability`                | *flag*                        | Takes account of the model reliability option in the node settings\.                                                                             |
| `enable_sql_generation`            | `false`  <br>`native`         | When using data from a database, SQL code can be pushed back to the database for execution, providing superior performance for many operations\. |

<!-- </table "summary="applyselflearningnode properties" id="selflearnnuggetnodeslots__table_czt_2wy_ddb" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# applysequencenode properties #

You can use Sequence modeling nodes to generate a Sequence model nugget\. The scripting name of this model nugget is *applysequencenode*\. No other properties exist for this model nugget\. For more information on scripting the modeling node itself, see [sequencenode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/sequencenodeslots.html#sequencenodeslots)\.

<!-- </article "role="article" "> -->
# setglobalsnode properties #

![Set Globals node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/setglobalsnodeicon.png)The Set Globals node scans the data and computes summary values that can be used in CLEM expressions\. For example, you can use this node to compute statistics for a field called `age` and then use the overall mean of `age` in CLEM expressions by inserting the function `@GLOBAL_MEAN(age)`\.

<!-- <table "summary="setglobalsnode properties" class="defaultstyle" "> -->

setglobalsnode properties  

Table 1\. setglobalsnode properties

| `setglobalsnode` properties | Data type                 | Property description                                                                                                                                                     |
| --------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `globals`                   | `[Sum Mean Min Max SDev]` | Structured property where fields to be set must be referenced with the following syntax: `node.setKeyedPropertyValue( "globals", "Age", ["Max", "Sum", "Mean", "SDev"])` |
| `clear_first`               | *flag*                    |                                                                                                                                                                          |
| `show_preview`              | *flag*                    |                                                                                                                                                                          |

<!-- </table "summary="setglobalsnode properties" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->