ibm-research/WatsonxDocsQARetrieval huggingface dataset:
# extensionoutputnode properties #

![Extension Output node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/extensionoutputnode.png)With the Extension Output node, you can analyze data and the results of model scoring using your own custom R or Python for Spark script\. The output of the analysis can be text or graphical\.

Note that many of the properties on this page are for streams from SPSS Modeler desktop\.

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

extensionoutputnode properties  

Table 1\. extensionoutputnode properties

| `extensionoutputnode` properties | Data type                         | Property description                                                                      |
| -------------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------- |
| `syntax_type`                    | *R**Python*                       | Specify which script runs: R or Python (R is the default)\.                               |
| `r_syntax`                       | *string*                          | R scripting syntax for model scoring\.                                                    |
| `python_syntax`                  | *string*                          | Python scripting syntax for model scoring\.                                               |
| `convert_flags`                  | `StringsAndDoubles LogicalValues` | Option to convert flag fields\.                                                           |
| `convert_missing`                | *flag*                            | Option to convert missing values to the R NA value\.                                      |
| `convert_datetime`               | *flag*                            | Option to convert variables with date or datetime formats to R date/time formats\.        |
| `convert_datetime_class`         | `POSIXct POSIXlt`                 | Options to specify to what format variables with date or datetime formats are converted\. |
| `output_to`                      | `Screen File`                     | Specify the output type (`Screen` or `File`)\.                                            |
| `output_type`                    | `Graph Text`                      | Specify whether to produce graphical or text output\.                                     |
| `full_filename`                  | *string*                          | File name to use for the generated output\.                                               |
| `graph_file_type`                | `HTML COU`                        | File type for the output file ( \.html or  \.cou)\.                                       |
| `text_file_type`                 | `HTML TEXT COU`                   | Specify the file type for text output ( \.html,  \.txt, or  \.cou)\.                      |

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

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

![Extension Transform node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/extensionprocessnode.png) With the Extension Transform node, you can take data from a flow and apply transformations to the data using R scripting or Python for Spark scripting\.

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

extensionprocessnode properties  

Table 1\. extensionprocessnode properties

| `extensionprocessnode` properties | Data type                         | Property description                                                                      |
| --------------------------------- | --------------------------------- | ----------------------------------------------------------------------------------------- |
| `syntax_type`                     | *R**Python*                       | Specify which script runs – R or Python (R is the default)\.                              |
| `r_syntax`                        | *string*                          | The R scripting syntax to run\.                                                           |
| `python_syntax`                   | *string*                          | The Python scripting syntax to run\.                                                      |
| `use_batch_size`                  | *flag*                            | Enable use of batch processing\.                                                          |
| `batch_size`                      | *integer*                         | Specify the number of data records to include in each batch\.                             |
| `convert_flags`                   | `StringsAndDoubles LogicalValues` | Option to convert flag fields\.                                                           |
| `convert_missing`                 | *flag*                            | Option to convert missing values to the R NA value\.                                      |
| `convert_datetime`                | *flag*                            | Option to convert variables with date or datetime formats to R date/time formats\.        |
| `convert_datetime_class`          | `POSIXct POSIXlt`                 | Options to specify to what format variables with date or datetime formats are converted\. |

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

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

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

<!-- </article "role="article" "> -->
# Setting algorithm properties #

For the Auto Classifier, Auto Numeric, and Auto Cluster nodes, you can set properties for specific algorithms used by the node by using the general form:

    autonode.setKeyedPropertyValue(<algorithm>, <property>, <value>)

For example:

    node.setKeyedPropertyValue("neuralnetwork", "method", "MultilayerPerceptron")

Algorithm names for the Auto Classifier node are `cart`, `chaid`, `quest`, `c50`, `logreg`, `decisionlist`, `bayesnet`, `discriminant`, `svm` and `knn`\.

Algorithm names for the Auto Numeric node are `cart`, `chaid`, `neuralnetwork`, `genlin`, `svm`, `regression`, `linear` and `knn`\.

Algorithm names for the Auto Cluster node are `twostep`, `k-means`, and `kohonen`\.

Property names are standard as documented for each algorithm node\.

Algorithm properties that contain periods or other punctuation must be wrapped in single quotes\. For example:

    node.setKeyedPropertyValue("logreg", "tolerance", "1.0E-5")

Multiple values can also be assigned for a property\. For example:

    node.setKeyedPropertyValue("decisionlist", "search_direction", ["Up", "Down"])

To enable or disable the use of a specific algorithm:

    node.setPropertyValue("chaid", True)

Note: In cases where certain algorithm options aren't available in the Auto Classifier node, or when only a single value can be specified rather than a range of values, the same limits apply with scripting as when accessing the node in the standard manner\.
<!-- </article "role="article" "> -->
# applyfeatureselectionnode properties #

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

<!-- <table "summary="applyfeatureselectionnode properties" id="featureselectionnuggetnodeslots__table_u2v_kcj_cdb" class="defaultstyle" "> -->

applyfeatureselectionnode properties  

Table 1\. applyfeatureselectionnode properties

| `applyfeatureselectionnode` Properties | Values | Property description                                               |
| -------------------------------------- | ------ | ------------------------------------------------------------------ |
| `ranked_values`                        |        | Specifies which ranked fields are checked in the model browser\.   |
| `screened_values`                      |        | Specifies which screened fields are checked in the model browser\. |

<!-- </table "summary="applyfeatureselectionnode properties" id="featureselectionnuggetnodeslots__table_u2v_kcj_cdb" class="defaultstyle" "> -->

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

![Filler node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/fillernodeicon.png)The Filler node replaces field values and changes storage\. You can choose to replace values based on a CLEM condition, such as `@BLANK(@FIELD)`\. Alternatively, you can choose to replace all blanks or null values with a specific value\. A Filler node is often used together with a Type node to replace missing values\.

Example

    node = stream.create("filler", "My node")
    node.setPropertyValue("fields", ["Age"])
    node.setPropertyValue("replace_mode", "Always")
    node.setPropertyValue("condition", "(\"Age\" > 60) and (\"Sex\" = \"M\"")
    node.setPropertyValue("replace_with", "\"old man\"")

<!-- <table "summary="fillernode properties" id="fillernodeslots__table_e3h_ncj_cdb" class="defaultstyle" "> -->

fillernode properties  

Table 1\. fillernode properties

| `fillernode` properties | Data type                                        | Property description                                                                                  |
| ----------------------- | ------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| `fields`                | *list*                                           | Fields from the dataset whose values will be examined and replaced\.                                  |
| `replace_mode`          | `Always``Conditional``Blank``Null``BlankAndNull` | You can replace all values, blank values, or null values, or replace based on a specified condition\. |
| `condition`             | *string*                                         |                                                                                                       |
| `replace_with`          | *string*                                         |                                                                                                       |

<!-- </table "summary="fillernode properties" id="fillernodeslots__table_e3h_ncj_cdb" class="defaultstyle" "> -->

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

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

<!-- <table "summary="applygeneralizedlinearnode properties" id="genlinnuggetnodeslots__table_sfv_rcj_cdb" class="defaultstyle" "> -->

applygeneralizedlinearnode properties  

Table 1\. applygeneralizedlinearnode properties

| `applygeneralizedlinearnode` Properties | Values          | Property description                                                                                                                             |
| --------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `calculate_raw_propensities`            | *flag*          |                                                                                                                                                  |
| `calculate_adjusted_propensities`       | *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="applygeneralizedlinearnode properties" id="genlinnuggetnodeslots__table_sfv_rcj_cdb" class="defaultstyle" "> -->

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

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

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

applygle properties  

Table 1\. applygle properties

| `applygle` Properties   | 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="applygle properties" class="defaultstyle" "> -->

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

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

<!-- <table "summary="applyglmmnode properties" id="glmmnuggetnodeslots__table_ywy_scj_cdb" class="defaultstyle" "> -->

applyglmmnode properties  

Table 1\. applyglmmnode properties

| `applyglmmnode` Properties     | Values                      | Property description                                                                                                                                                                                                                       |
| ------------------------------ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `confidence`                   | `onProbability``onIncrease` | Basis for computing scoring confidence value: highest predicted probability, or difference between highest and second highest predicted probabilities\.                                                                                    |
| `score_category_probabilities` | *flag*                      | If set to `True`, produces the predicted probabilities for categorical targets\. A field is created for each category\. Default is `False`\.                                                                                               |
| `max_categories`               | *integer*                   | Maximum number of categories for which to predict probabilities\. Used only if `score_category_probabilities` is `True`\.                                                                                                                  |
| `score_propensity`             | *flag*                      | If set to `True`, produces raw propensity scores (likelihood of "True" outcome) for models with flag targets\. If partitions are in effect, also produces adjusted propensity scores based on the testing partition\. Default is `False`\. |
| `enable_sql_generation`        | `false``true``native`       | Used to set SQL generation options during flow execution\. The options are to push back to the database, or to score within SPSS Modeler\.                                                                                                 |

<!-- </table "summary="applyglmmnode properties" id="glmmnuggetnodeslots__table_ywy_scj_cdb" class="defaultstyle" "> -->

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

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

<!-- <table "summary="applygmm properties" id="gmmnuggetnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

applygmm properties  

Table 1\. applygmm properties

| `applygmm` properties | Data type | Property description |
| --------------------- | --------- | -------------------- |
| `centers`             |           |                      |
| `item_count`          |           |                      |
| `total`               |           |                      |
| `dimension`           |           |                      |
| `components`          |           |                      |
| `partition`           |           |                      |

<!-- </table "summary="applygmm properties" id="gmmnuggetnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

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

You can use the Association Rules modeling node to generate an association rules model nugget\. The scripting name of this model nugget is *applyassociationrulesnode*\. For more information on scripting the modeling node itself, see [associationrulesnode properties](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/gsarnodeslots.html#gsarnodeslots)\.

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

applyassociationrulesnode properties  

Table 1\. applyassociationrulesnode properties

| `applyassociationrulesnode` properties | Data type                                                        | Property description                                                         |
| -------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| `max_predictions`                      | *integer*                                                        | The maximum number of rules that can be applied to each input to the score\. |
| `criterion`                            | `Confidence``Rulesupport``Lift``Conditionsupport``Deployability` | Select the measure used to determine the strength of rules\.                 |
| `allow_repeats`                        | *Boolean*                                                        | Determine whether rules with the same prediction are included in the score\. |
| `check_input`                          | `NoPredictions``Predictions``NoCheck`                            |                                                                              |

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

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

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

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

![History node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/historynodeicon.png)The History node creates new fields containing data from fields in previous records\. History nodes are most often used for sequential data, such as time series data\. Before using a History node, you may want to sort the data using a Sort node\.

Example

    node = stream.create("history", "My node")
    node.setPropertyValue("fields", ["Drug"])
    node.setPropertyValue("offset", 1)
    node.setPropertyValue("span", 3)
    node.setPropertyValue("unavailable", "Discard")
    node.setPropertyValue("fill_with", "undef")

<!-- <table "summary="historynode properties" id="historynodeslots__table_ypd_vcj_cdb" class="defaultstyle" "> -->

historynode properties  

Table 1\. historynode properties

| `historynode` properties | Data type              | Property description                                                                                                                                                                             |
| ------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `fields`                 | *list*                 | Fields for which you want a history\.                                                                                                                                                            |
| `offset`                 | *number*               | Specifies the latest record (prior to the current record) from which you want to extract historical field values\.                                                                               |
| `span`                   | *number*               | Specifies the number of prior records from which you want to extract values\.                                                                                                                    |
| `unavailable`            | `Discard``Leave``Fill` | For handling records that have no history values, usually referring to the first several records (at the beginning of the dataset) for which there are no previous records to use as a history\. |
| `fill_with`              | `String``Number`       | Specifies a value or string to be used for records where no history value is available\.                                                                                                         |

<!-- </table "summary="historynode properties" id="historynodeslots__table_ypd_vcj_cdb" class="defaultstyle" "> -->

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

![Isotonic\-AS node icon](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/images/sparkisotonicasnodeicon.png)Isotonic Regression belongs to the family of regression algorithms\. The Isotonic\-AS node in SPSS Modeler is implemented in Spark\. For details about Isotonic Regression algorithms, see [https://spark\.apache\.org/docs/2\.2\.0/mllib\-isotonic\-regression\.html](https://spark.apache.org/docs/2.2.0/mllib-isotonic-regression.html)\.

<!-- <table "summary="isotonicasnode properties" id="isotonicasnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

isotonicasnode properties  

Table 1\. isotonicasnode properties

| `isotonicasnode` properties | Data type | Property description                                                                                 |
| --------------------------- | --------- | ---------------------------------------------------------------------------------------------------- |
| `label`                     | *string*  | This property is a dependent variable for which isotonic regression is calculated\.                  |
| `features`                  | *string*  | This property is an independent variable\.                                                           |
| `weightCol`                 | *string*  | The weight represents a number of measures\. Default is `1`\.                                        |
| `isotonic`                  | *Boolean* | This property indicates whether the type is `isotonic` or `antitonic`\.                              |
| `featureIndex`              | *integer* | This property is for the index of the feature if `featuresCol` is a vector column\. Default is `0`\. |

<!-- </table "summary="isotonicasnode properties" id="isotonicasnodeslots__table_r3k_5bw_tz" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# Python and Jython #

Jython is an implementation of the Python scripting language, which is written in the Java language and integrated with the Java platform\. Python is a powerful object\-oriented scripting language\.

Jython is useful because it provides the productivity features of a mature scripting language and, unlike Python, runs in any environment that supports a Java virtual machine (JVM)\. This means that the Java libraries on the JVM are available to use when you're writing programs\. With Jython, you can take advantage of this difference, and use the syntax and most of the features of the Python language\.

As a scripting language, Python (and its Jython implementation) is easy to learn and efficient to code, and has minimal required structure to create a running program\. Code can be entered interactively, that is, one line at a time\. Python is an interpreted scripting language; there is no precompile step, as there is in Java\. Python programs are simply text files that are interpreted as they're input (after parsing for syntax errors)\. Simple expressions, like defined values, as well as more complex actions, such as function definitions, are immediately executed and available for use\. Any changes that are made to the code can be tested quickly\. Script interpretation does, however, have some disadvantages\. For example, use of an undefined variable is not a compiler error, so it's detected only if (and when) the statement in which the variable is used is executed\. In this case, you can edit and run the program to debug the error\.

Python sees everything, including all data and code, as an object\. You can, therefore, manipulate these objects with lines of code\. Some select types, such as numbers and strings, are more conveniently considered as values, not objects; this is supported by Python\. There is one null value that's supported\. This null value has the reserved name `None`\.

For a more in\-depth introduction to Python and Jython scripting, and for some example scripts, see [http://www\.ibm\.com/developerworks/java/tutorials/j\-jython1/j\-jython1\.html](http://www.ibm.com/developerworks/java/tutorials/j-jython1/j-jython1.html) and [http://www\.ibm\.com/developerworks/java/tutorials/j\-jython2/j\-jython2\.html](http://www.ibm.com/developerworks/java/tutorials/j-jython2/j-jython2.html)\.

<!-- </article "role="article" "> -->
# Adding attributes to a class instance #

Unlike in Java, in Python clients can add attributes to an instance of a class\. Only the one instance is changed\. For example, to add attributes to an instance `x`, set new values on that instance:

    x.attr1 = 1
    x.attr2 = 2
        .
        .
    x.attrN = n

<!-- </article "role="article" "> -->
# The scripting API #

The Scripting API provides access to a wide range of SPSS Modeler functionality\. All the methods described so far are part of the API and can be accessed implicitly within the script without further imports\. However, if you want to reference the API classes, you must import the API explicitly with the following statement:

    import modeler.api

This import statement is required by many of the scripting API examples\.

<!-- </article "role="article" "> -->
# Example: Searching for nodes using a custom filter #

The section [Finding nodes](https://dataplatform.cloud.ibm.com/docs/content/wsd/nodes/scripting_guide/clementine/jython/clementine/python_node_find.html#python_node_find) includes an example of searching for a node in a flow using the type name of the node as the search criterion\. In some situations, a more generic search is required and this can be accomplished by using the `NodeFilter` class and the flow `findAll()` method\. This type of search involves the following two steps:

<!-- <ol> -->

1.  Creating a new class that extends `NodeFilter` and that implements a custom version of the `accept()` method\.
2.  Calling the flow `findAll()` method with an instance of this new class\. This returns all nodes that meet the criteria defined in the `accept()` method\.

<!-- </ol> -->

The following example shows how to search for nodes in a flow that have the node cache enabled\. The returned list of nodes can be used to either flush or disable the caches of these nodes\.

    import modeler.api
    
    class CacheFilter(modeler.api.NodeFilter):
    	"""A node filter for nodes with caching enabled"""
    	def accept(this, node):
    		return node.isCacheEnabled()
    
    cachingnodes = modeler.script.stream().findAll(CacheFilter(), False)

<!-- </article "role="article" "> -->
# Defining a class #

Within a Python class, you can define both variables and methods\. Unlike in Java, in Python you can define any number of public classes per source file (or module)\. Therefore, you can think of a module in Python as similar to a package in Java\.

In Python, classes are defined using the `class` statement\. The `class` statement has the following form:

    class name (superclasses): statement

or

    class name (superclasses): 
        assignment
        .
        .
        function
        .
        .

When you define a class, you have the option to provide zero or more assignment statements\. These create class attributes that are shared by all instances of the class\. You can also provide zero or more function definitions\. These function definitions create methods\. The `superclasses` list is optional\.

The class name should be unique in the same scope, that is within a module, function, or class\. You can define multiple variables to reference the same class\.

<!-- </article "role="article" "> -->
# Creating a class instance #

You can use classes to hold class (or shared) attributes or to create class instances\. To create an instance of a class, you call the class as if it were a function\. For example, consider the following class:

    class MyClass:
        pass

Here, the `pass` statement is used because a statement is required to complete the class, but no action is required programmatically\.

The following statement creates an instance of the class `MyClass`:

    x = MyClass()

<!-- </article "role="article" "> -->
# Defining class attributes and methods #

Any variable that's bound in a class is a class attribute\. Any function defined within a class is a method\. Methods receive an instance of the class, conventionally called `self`, as the first argument\. For example, to define some class attributes and methods, you might enter the following script:

    class MyClass
        attr1 = 10        #class attributes
        attr2 = "hello"
    
        def method1(self):
            print MyClass.attr1   #reference the class attribute
    
        def method2(self):
            print MyClass.attr2   #reference the class attribute
    
        def method3(self, text):
            self.text = text        #instance attribute
            print text, self.text   #print my argument and my attribute
    
        method4 = method3   #make an alias for method3

Inside a class, you should qualify all references to class attributes with the class name (for example, `MyClass.attr1`)\. All references to instance attributes should be qualified with the `self` variable (for example, `self.text`)\. Outside the class, you should qualify all references to class attributes with the class name (for example, `MyClass.attr1`) or with an instance of the class (for example, `x.attr1`, where `x` is an instance of the class)\. Outside the class, all references to instance variables should be qualified with an instance of the class (for example, `x.text`)\.

<!-- </article "role="article" "> -->
# Global values #

Global values are used to compute various summary statistics for specified fields\. These summary values can be accessed anywhere within the flow\. Global values are similar to flow parameters in that they are accessed by name through the flow\. They're different from flow parameters in that the associated values are updated automatically when a Set Globals node is run, rather than being assigned by scripting\. The global values for a flow are accessed by calling the flow's `getGlobalValues()` method\.

The `GlobalValues` object defines the functions that are shown in the following table\.

<!-- <table "summary="Functions that are defined by the GlobalValues object" class="defaultstyle" "> -->

Functions that are defined by the GlobalValues object  

Table 1\. Functions that are defined by the GlobalValues object

| Method                        | Return type | Description                                                                                                                                                                                                                      |
| ----------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `g.fieldNameIterator()`       | Iterator    | Returns an iterator for each field name with at least one global value\.                                                                                                                                                         |
| `g.getValue(type, fieldName)` | Object      | Returns the global value for the specified type and field name, or `None` if no value can be located\. The returned value is generally expected to be a number, although future functionality may return different value types\. |
| `g.getValues(fieldName)`      | Map         | Returns a map containing the known entries for the specified field name, or `None` if there are no existing entries for the field\.                                                                                              |

<!-- </table "summary="Functions that are defined by the GlobalValues object" class="defaultstyle" "> -->

`GlobalValues.Type` defines the type of summary statistics that are available\. The following summary statistics are available:

<!-- <ul> -->

 *  `MAX`: the maximum value of the field\.
 *  `MEAN`: the mean value of the field\.
 *  `MIN`: the minimum value of the field\.
 *  `STDDEV`: the standard deviation of the field\.
 *  `SUM`: the sum of the values in the field\.

<!-- </ul> -->

For example, the following script accesses the mean value of the "income" field, which is computed by a Set Globals node:

    import modeler.api
    
    globals = modeler.script.stream().getGlobalValues()
    mean_income = globals.getValue(modeler.api.GlobalValues.Type.MEAN, "income")

<!-- </article "role="article" "> -->
# Hidden variables #

You can hide data by creating Private variables\. Private variables can be accessed only by the class itself\. If you declare names of the form `__xxx` or `__xxx_yyy`, that is with two preceding underscores, the Python parser will automatically add the class name to the declared name, creating hidden variables\. For example:

    class MyClass:
        __attr = 10   #private class attribute
    
        def method1(self):
            pass
    
        def method2(self, p1, p2):
            pass
    
        def __privateMethod(self, text):
            self.__text = text    #private attribute

Unlike in Java, in Python all references to instance variables must be qualified with `self`; there's no implied use of `this`\.

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

The ability to inherit from classes is fundamental to object\-oriented programming\. Python supports both single and multiple inheritance\. Single inheritance means that there can be only one superclass\. Multiple inheritance means that there can be more than one superclass\.

Inheritance is implemented by subclassing other classes\. Any number of Python classes can be superclasses\. In the Jython implementation of Python, only one Java class can be directly or indirectly inherited from\. It's not required for a superclass to be supplied\.

Any attribute or method in a superclass is also in any subclass and can be used by the class itself, or by any client as long as the attribute or method isn't hidden\. Any instance of a subclass can be used wherever an instance of a superclass can be used; this is an example of polymorphism\. These features enable reuse and ease of extension\.

<!-- </article "role="article" "> -->
# The scripting language #

With the scripting facility for SPSS Modeler, you can create scripts that operate on the SPSS Modeler user interface, manipulate output objects, and run command syntax\. You can also run scripts directly from within SPSS Modeler\.

Scripts in SPSS Modeler are written in the Python scripting language\. The Java\-based implementation of Python that's used by SPSS Modeler is called Jython\. The scripting language consists of the following features:

<!-- <ul> -->

 *  A format for referencing nodes, flows, projects, output, and other SPSS Modeler objects
 *  A set of scripting statements or commands you can use to manipulate these objects
 *  A scripting expression language for setting the values of variables, parameters, and other objects
 *  Support for comments, continuations, and blocks of literal text

<!-- </ul> -->

The following sections of this documentation describe the Python scripting language, the Jython implementation of Python, and the basic syntax for getting started with scripting in SPSS Modeler\. Information about specific properties and commands is provided in the sections that follow\.

<!-- </article "role="article" "> -->
# Creating nodes #

Flows provide a number of ways to create nodes\. These methods are summarized in the following table\.

<!-- <table "summary="Methods for creating nodes" class="defaultstyle" "> -->

Methods for creating nodes  

Table 1\. Methods for creating nodes

| Method                                    | Return type | Description                                                                                                                                                  |
| ----------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `s.create(nodeType, name)`                | Node        | Creates a node of the specified type and adds it to the specified flow\.                                                                                     |
| `s.createAt(nodeType, name, x, y)`        | Node        | Creates a node of the specified type and adds it to the specified flow at the specified location\. If either x < 0 or y < 0, the location is not set\. |
| `s.createModelApplier(modelOutput, name)` | Node        | Creates a model applier node that's derived from the supplied model output object\.                                                                          |

<!-- </table "summary="Methods for creating nodes" class="defaultstyle" "> -->

For example, you can use the following script to create a new Type node in a flow:

    stream = modeler.script.stream()
    # Create a new Type node
    node = stream.create("type", "My Type")

<!-- </article "role="article" "> -->
# Traversing through nodes in a flow #

A common requirement is to identify nodes that are either upstream or downstream of a particular node\. The flow provides a number of methods that can be used to identify these nodes\. These methods are summarized in the following table\.

<!-- <table "summary="Methods to identify upstream and downstream nodes" class="defaultstyle" "> -->

Methods to identify upstream and downstream nodes  

Table 1\. Methods to identify upstream and downstream nodes

| Method                         | Return type | Description                                                                                                                                                                                      |
| ------------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `s.iterator()`                 | Iterator    | Returns an iterator over the node objects that are contained in the specified flow\. If the flow is modified between calls of the `next()` function, the behavior of the iterator is undefined\. |
| `s.predecessorAt(node, index)` | Node        | Returns the specified immediate predecessor of the supplied node or `None` if the index is out of bounds\.                                                                                       |
| `s.predecessorCount(node)`     | *int*       | Returns the number of immediate predecessors of the supplied node\.                                                                                                                              |
| `s.predecessors(node)`         | List        | Returns the immediate predecessors of the supplied node\.                                                                                                                                        |
| `s.successorAt(node, index)`   | Node        | Returns the specified immediate successor of the supplied node or `None` if the index is out of bounds\.                                                                                         |
| `s.successorCount(node)`       | *int*       | Returns the number of immediate successors of the supplied node\.                                                                                                                                |
| `s.successors(node)`           | List        | Returns the immediate successors of the supplied node\.                                                                                                                                          |

<!-- </table "summary="Methods to identify upstream and downstream nodes" class="defaultstyle" "> -->

<!-- </article "role="article" "> -->
# Object\-oriented programming #

Object\-oriented programming is based on the notion of creating a model of the target problem in your programs\. Object\-oriented programming reduces programming errors and promotes the reuse of code\. Python is an object\-oriented language\. Objects defined in Python have the following features:

<!-- <ul> -->

 *  Identity\. Each object must be distinct, and this must be testable\. The `is` and `is not` tests exist for this purpose\.
 *  State\. Each object must be able to store state\. Attributes, such as fields and instance variables, exist for this purpose\.
 *  Behavior\. Each object must be able to manipulate its state\. Methods exist for this purpose\.

<!-- </ul> -->

Python includes the following features for supporting object\-oriented programming:

<!-- <ul> -->

 *  Class\-based object creation\. Classes are templates for the creation of objects\. Objects are data structures with associated behavior\.
 *  Inheritance with polymorphism\. Python supports single and multiple inheritance\. All Python instance methods are polymorphic and can be overridden by subclasses\.
 *  Encapsulation with data hiding\. Python allows attributes to be hidden\. When hidden, you can access attributes from outside the class only through methods of the class\. Classes implement methods to modify the data\.

<!-- </ul> -->

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

Nodes, flows, models, and outputs all have properties that can be accessed and, in most cases, set\. Properties are typically used to modify the behavior or appearance of the object\. The methods that are available for accessing and setting object properties are summarized in the following table\.

<!-- <table "summary="Methods for accessing and setting object properties" class="defaultstyle" "> -->

Methods for accessing and setting object properties  

Table 1\. Methods for accessing and setting object properties

| Method                                                   | Return type    | Description                                                                                                                                                                             |
| -------------------------------------------------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `p.getPropertyValue(propertyName)`                       | Object         | Returns the value of the named property or `None` if no such property exists\.                                                                                                          |
| `p.setPropertyValue(propertyName, value)`                | Not applicable | Sets the value of the named property\.                                                                                                                                                  |
| `p.setPropertyValues(properties)`                        | Not applicable | Sets the values of the named properties\. Each entry in the properties map consists of a key that represents the property name and the value that should be assigned to that property\. |
| `p.getKeyedPropertyValue( propertyName, keyName)`        | Object         | Returns the value of the named property and associated key or `None` if no such property or key exists\.                                                                                |
| `p.setKeyedPropertyValue( propertyName, keyName, value)` | Not applicable | Sets the value of the named property and key\.                                                                                                                                          |

<!-- </table "summary="Methods for accessing and setting object properties" class="defaultstyle" "> -->

For example, the following script sets the value of a Derive node for a flow:

    stream = modeler.script.stream()
    node = stream.findByType("derive", None)
    node.setPropertyValue("name_extension", "new_derive")

Alternatively, you might want to filter a field from a Filter node\. In this case, the value is also keyed on the field name\. For example:

    stream = modeler.script.stream()
    # Locate the filter node ...
    node = stream.findByType("filter", None)
    # ... and filter out the "Na" field
    node.setKeyedPropertyValue("include", "Na", False)

<!-- </article "role="article" "> -->
# Running a flow #

The following example runs all executable nodes in the flow, and is the simplest type of flow script:

    modeler.script.stream().runAll(None)

The following example also runs all executable nodes in the flow:

    stream = modeler.script.stream()
    stream.runAll(None)

In this example, the flow is stored in a variable called `stream`\. Storing the flow in a variable is useful because a script is typically used to modify either the flow or the nodes within a flow\. Creating a variable that stores the flow results in a more concise script\.

<!-- </article "role="article" "> -->
# Flows, SuperNode streams, and diagrams #

Most of the time, the term flow means the same thing, regardless of whether it's a flow that's loaded from a file or used within a SuperNode\. It generally means a collection of nodes that are connected together and can be executed\. In scripting, however, not all operations are supported in all places\. So as a script author, you should be aware of which flow variant they're using\.

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