Python Predictor

This Node Is Deprecated — This node is kept for backwards-compatibility, but the usage in new workflows is no longer recommended. The documentation below might contain more information.

Allows execution of a Python script in a local Python installation. The path to the Python executable has to be configured in Preferences → KNIME → Python. This node supports Python 2 and 3.

Options

Script

Editor
The script in the editor panel in the center will be executed to generate this node's output. "Execute script" will execute the full script while "Execute selected lines" will only execute the currently selected part of the script.

The editor optionally provides autocompletion (CTRL + Space) if the Python module jedi is installed.
Flow variables
The pane on the left side of the editor panel lists the available flow variables. A double click on a flow variable will insert the corresponding identifier at the current cursor position in the editor panel.
Workspace
The pane on the right side of the editor panel is the workspace and lists the currently defined identifiers in the running Python instance. "Reset workspace" will remove the output of all past script executions.
Console
The console under the editor panel displays standard output, standard error, or other information.
Row limit (dialog)
Limits how many rows are loaded in the dialog. Changes only take effect after reseting the workspace.
Use python version
Allows to choose the python version that should be used for executing the kernel. Available installations can be checked under Preferences → KNIME → Python.
Missing values (Int, Long)
By default, Int and Long columns containing missing values are converted to doubles in Python, because doubles are the only numeric type containing a built-in missing value representation (NaN). Converting longs to doubles, however, introduces imprecision. The conversion may be avoided by replacing missing values with so-called sentinel values. To convert missing values to sentinel values before script execution, check the first option, to convert sentinel values back to missing values after script execution, check the second option. To select a sentinel value, click on MIN_VAL (the smallest possible value for the column's data type), MAX_VAL (the largest possible value for the column's data type), or a manually enter an integer in the text field.
Rows per chunk
Large tables are broken into chunks when they are transferred between Python and Java. This option controls how many rows are included in each chunk. The default value is intended for tables containing few columns having numeric types. If larger data types like images or text are transferred, a single chunk may exceed the maximum allowed buffer size. In this case lowering the value of this parameter helps getting reasonably sized chunks.

Templates

Create from editor...
Clicking on this button creates a new template based on the script in the editor panel of the script tab.

Note: User defined templates can be found in the folder: knime-workspace/.metadata/knime/sourcecode-templates/python-predictor
Remove selected
Clicking on this button removes the selected template.

Note: Templates provided by plugins cannot be removed.
Apply selected
Replaces the script in the editor panel of the script tab with the selected template.

Input Ports

Icon
The trained model. In the Python script it is available under the name input_model .
Icon
The input table. In the Python script it is available as pandas.DataFrame under the name input_table .

Output Ports

Icon
The output table. This is the content of the variable output_table which has to be defined and has to be of the type pandas.DataFrame for this node to successfully execute.

Views

Standard output
The text sent by Python to the standard output, during the execution of this node.
Error output
The text sent by Python to the error output, during the execution of this node.

Workflows

Links

Developers

You want to see the source code for this node? Click the following button and we’ll use our super-powers to find it for you.