Initializing help system before first use

Data Model

Topics covered in this chapter:

All entities in the data model must be declared with the help of type hints for the class attributes.

Parameters

Parameters are scalar values that can be used to configure an Insight scenario. When parameters are declared, their name, data type, and default value must be specified. The data type can be omitted if the default value is specified and vice versa. Parameter values are automatically passed from the scenario to Insight app such that their value from the scenario is available in all execution modes. In particular, the parameter values are available in the standard load mode. Within the Insight execution mode, parameters should be treated as runtime constants. They can only be changed in the Insight user interface and any changes in an execution mode will not be transferred back to the Insight server, i.e., the scenario parameters remain unchanged. Some examples include:

import xpressinsight as xi

@xi.AppConfig(name="My First Insight Python App", version=xi.AppVersion(0, 1, 2))
class MyApp(xi.AppBase):

    # Examples where data type is inferred from the default value.
    # Parameter "P" of type "xi.integer" with default value 100.
    P: xi.Param(100)
    # Parameter "DEBUG" of type "xi.boolean" with default value False.
    DEBUG: xi.Param(False)
    # Parameter "PI" of type "xi.real" with default value 3.14.
    PI: xi.Param(3.14)
    # Parameter "STR_PARAM" of type xi.string with default value 'My String Param'.
    STR_PARAM: xi.Param('My String Param')

    # Examples where data type is explicitly given.
    BOOL_PARAM: xi.Param(dtype=xi.boolean)   # Default value False.
    INT_PARAM: xi.Param(dtype=xi.integer)    # Default value 0.
    REAL_PARAM: xi.Param(dtype=xi.real)      # Default value 0.0.
    STRING_PARAM: xi.Param(dtype=xi.string)  # Default value "".

    # TODO: Define execution modes here.

Parameters are typically read-only.

Scalars

Scalar values are used to represent single-valued entities in the data model. Like parameters, when scalars are declared, their name, data type, and default value must be specified. The data type can be omitted if the default value is specified and vice versa. Scalars can either be input values or result values. By default, scalars are treated as input values. Some examples include:

import xpressinsight as xi

@xi.AppConfig(name="My First Insight Python App", version=xi.AppVersion(0, 1, 2))
class MyApp(xi.AppBase):

    # Examples where data type is inferred from the default value.
    # Input scalar "NumFactory" of type "xi.integer" with default value 100.
    NumFactory: xi.Scalar(100, manage=xi.Manage.INPUT)
    # Result scalar "IsOn" of type "xi.boolean" with default value True.
    IsOn: xi.Scalar(True, manage=xi.Manage.RESULT)

    # Examples where data type is explicitly given.
    StringScalar: xi.Scalar(dtype=xi.string)  # Input scalar with default value "".
    RealScalar: xi.Scalar(dtype=xi.real)      # Input scalar with default value 0.0.

    # TODO: Define execution modes here.

General Notes

In the data model, entities may be assigned an alias, which allows to specify a more "user-friendly" label for the entity which will be used in the Insight UI. For example:

MyInteger: xi.Scalar(dtype=xi.integer, alias='My Integer')

An entity MyInteger is declared, but will appear as My Integer in the Insight app UI such as table column headers, entity explorer, etc..

Data Model Classes

Declare the entity to be (or to contain) boolean (True or False) values. If not specified, the default value is False.
Represent a single column within a DataFrame entity.
Initializes Column.
Represent a DataFrame entity.
Initializes DataFrame.
Possible values of whether the UI should hide an entity where appropriate.
Represents an index entity. To be used in conjunction with xpressinsight.Series or xpressinsight.DataFrame objects.
The constructor.
Declare the entity to be (or to contain) integer (whole number) values. Each value must fit into a signed 32-bit integer. If not specified, the default value is 0.
How and whether Insight handles an entity.
Represents a parameter entity. Parameters can be used to configure an Xpress Insight app. When parameters are declared, their name, data type, and default value must be specified. Parameters are typically read-only.
Initializes Param with the data type or a default value (in which case data type is inferred).
Declare the entity to be (or to contain) floating-point (whole number) values. If not specified, the default value is 0.0.
Represents a scalar entity.
The constructor.
Represent a Series entity, a declaration of a pandas Series datastructure. Every series must has at least one index.
Initializes Series.
Declare the entity to be (or to contain) string (UTF-8 encoded) values. The length (in bytes) of a string scalar (Scalar or Param) must not exceed 1,000,000 bytes. The length of a string in a container (Index, Series, or DataFrame) must not exceed 250,000 characters. A string must not contain the null character. If not specified, the default value of a string scalar is the empty string "".

xpressinsight.boolean

Purpose
Declare the entity to be (or to contain) boolean ( True or False) values. If not specified, the default value is False.
Example
Example of declaring a scalar entity to be boolean.
>>> my_bool: xi.Scalar(dtype=xi.boolean)
... my_bool: xi.Scalar(False)
... my_bool: xi.Scalar(True)		
Related topics

xpressinsight.integer

Purpose
Declare the entity to be (or to contain) integer (whole number) values. Each value must fit into a signed 32-bit integer. If not specified, the default value is 0.
Example
Example of declaring a scalar entity to be integer.
>>> my_int: xi.Scalar(dtype=xi.integer)
... my_int: xi.Scalar(0)
... my_int: xi.Scalar(100)
... my_int: xi.Scalar(-10)		
Related topics

xpressinsight.real

Purpose
Declare the entity to be (or to contain) floating-point (whole number) values. If not specified, the default value is 0.0.
Example
Example of declaring a scalar entity to be a floating-point value.
>>> my_real: xi.Scalar(dtype=xi.real)
>>> my_real: xi.Scalar(100.0)
>>> my_real: xi.Scalar(123.456)		
Related topics

xpressinsight.string

Purpose
Declare the entity to be (or to contain) string (UTF-8 encoded) values. The length (in bytes) of a string scalar (Scalar or Param) must not exceed 1,000,000 bytes. The length of a string in a container (Index, Series, or DataFrame) must not exceed 250,000 characters. A string must not contain the null character. If not specified, the default value of a string scalar is the empty string "".
Example
Example of declaring a scalar entity to be a string.
>>> my_string: xi.Scalar(dtype=xi.string)
... my_string: xi.Scalar("Hello World!")		
Related topics

xpressinsight.Scalar

Purpose
Represents a scalar entity.
Example
Some examples of declaring scalar entities in the data model.
>>> @xi.AppConfig(name="My First Insight Python App",
...               version=xi.AppVersion(0, 1, 2))
... class MyApp(xi.AppBase):
...
...     # Examples where data type is inferred from default value
...     # Scalar "NumFactory" of type "xi.integer"; default value 10
...     NumFactory: xi.Scalar(10)
...     # Scalar "IsOn" of type "xi.boolean"; default value True
...     IsOn: xi.Scalar(True)
...
...     # Examples where data type is explicitly given.
...     RealScalar: xi.Scalar(dtype=xi.real)      # default value 0.0
...     StringScalar: xi.Scalar(dtype=xi.string)  # default value ""		
Related topics

xpressinsight.Scalar.__init__

Purpose
The constructor.
Synopsis
__init__(self, default: Union[str, bool, int, float] = None, dtype: Type[xpressinsight.BasicType] = None, alias: str = '', format: str = '', hidden: xpressinsight.Hidden = Hidden.FALSE, manage: xpressinsight.Manage = Manage.INPUT, read_only: bool = False, transform_labels_entity: str = '', update_after_execution: bool = False)
Arguments
default 
The default value.
dtype 
The data-type.
alias 
Used to provide an alternative name for an entity in the UI. The value is used in place of the entity name where appropriate in the UI.
format 
The formatting string used for displaying numeric values.
hidden 
Indicates whether the UI should hide the entity where appropriate.
manage 
How and whether Insight handles an entity. Defines how the system manages the entity data.
read_only 
Whether an entity is readonly. Specifies that the value(s) of the entity cannot be modified. See also hidden.
transform_labels_entity 
An entity in the schema to be used as a labels entity. The value is the name of the entity. The type of the index set of the labels entity much match the data type of this entity. The data type of the labels entity can be any primitive type.
update_after_execution 
Whether the value of the entity in the scenario is updated with the value of the corresponding model entity at the end of the scenario execution. If True the value of the entity is updated to correspond with the model entity after execution.

xpressinsight.Param

Purpose
Represents a parameter entity. Parameters can be used to configure an Xpress Insight app. When parameters are declared, their name, data type, and default value must be specified. Parameters are typically read-only.
Example
Some examples of declaring parameter entities in the data model.
>>> @xi.AppConfig(name="My First Insight Python App",
...               version=xi.AppVersion(0, 1, 2))
... class MyApp(xi.AppBase):
...
...     # examples where data type is inferred from the default value
...     # Param "P" of type "xi.integer" with default value 100
...     P: xi.Param(100)
...     # Param "DEBUG" of type "xi.boolean" with default value False
...     DEBUG: xi.Param(False)
...     # Param "PI" of type "xi.real" with default value 3.14
...     PI: xi.Param(3.14)
...     # Param "STR_PARAM" of type xi.string with a default value
...     STR_PARAM: xi.Param('My String Param')
...
...     # examples where data type is explicitly given
...     BOOL_PARAM: xi.Param(dtype=xi.boolean)  # default value False
...     INT_PARAM: xi.Param(dtype=xi.integer)  # default value 0
...     REAL_PARAM: xi.Param(dtype=xi.real)  # default value 0.0
...     STRING_PARAM: xi.Param(dtype=xi.string)  # default value ""		
Related topics

xpressinsight.Param.__init__

Purpose
Initializes Param with the data type or a default value (in which case data type is inferred).
Synopsis
__init__(self, default: Union[str, int, bool, float] = None, dtype: Type[xpressinsight.BasicType] = None)
Arguments
default: Union[str, int, bool, float] 
The default value.
dtype: BASIC_TYPE 
The data type of the parameter.

xpressinsight.Index

Purpose
Represents an index entity. To be used in conjunction with xpressinsight.Series or xpressinsight.DataFrame objects.
Example
Example creating an index of integer values with an alias.
>>> Indices: xi.Index(dtype=xi.integer, alias='Array Indices')		
Related topics

xpressinsight.Index.__init__

Purpose
The constructor.
Synopsis
__init__(self, dtype: Type[xpressinsight.BasicType], alias: str = '', format: str = '', hidden: xpressinsight.Hidden = Hidden.FALSE, manage: xpressinsight.Manage = Manage.INPUT, read_only: bool = False, transform_labels_entity: str = '', update_after_execution: bool = False)
Arguments
dtype 
The data-type.
alias 
Used to provide an alternative name for an entity in the UI. The value is used in place of the entity name where appropriate in the UI.
format 
The formatting string used for displaying numeric values.
hidden 
Indicates whether the UI should hide the entity where appropriate.
manage 
How and whether Insight handles an entity. Defines how the system manages the entity data.
read_only 
Whether an entity is readonly. Specifies that the value(s) of the entity cannot be modified. See also hidden.
transform_labels_entity 
An entity in the schema to be used as a labels entity. The value is the name of the entity. The type of the index set of the labels entity much match the data type of this entity. The data type of the labels entity can be any primitive type.
update_after_execution 
Whether the value of the entity in the scenario is updated with the value of the corresponding model entity at the end of the scenario execution. If True the value of the entity is updated to correspond with the model entity after execution.

xpressinsight.Series

Purpose
Represent a Series entity, a declaration of a pandas Series datastructure. Every series must has at least one index.
Example
Example of creating a Result series containing floating-point values, and is managed by Insight as a result entity. It is indexed by Indices, which must have been declared previously.
>>> Indices: xi.Index(...) # previous declaration
... Result: xi.Series(index=['Indices'], dtype=xi.real,
...                   manage=xi.Manage.RESULT, alias='Result Array')		
Related topics

xpressinsight.Series.__init__

Purpose
Initializes Series.
Synopsis
__init__(self, index: Union[str, List[str]], dtype: Type[xpressinsight.BasicType], alias: str = '', format: str = '', hidden: xpressinsight.Hidden = Hidden.FALSE, manage: xpressinsight.Manage = Manage.INPUT, read_only: bool = False, transform_labels_entity: str = '', update_after_execution: bool = False)
Arguments
index 
The index to use.
dtype 
The data-type.
alias 
Used to provide an alternative name for an entity in the UI. The value is used in place of the entity name where appropriate in the UI.
format 
The formatting string used for displaying numeric values.
hidden 
Indicates whether the UI should hide the entity where appropriate.
manage 
How and whether Insight handles an entity. Defines how the system manages the entity data.
read_only 
Whether an entity is readonly. Specifies that the value(s) of the entity cannot be modified. See also hidden.
transform_labels_entity 
An entity in the schema to be used as a labels entity. The value is the name of the entity. The type of the index set of the labels entity much match the data type of this entity. The data type of the labels entity can be any primitive type.
update_after_execution 
Whether the value of the entity in the scenario is updated with the value of the corresponding model entity at the end of the scenario execution. If True the value of the entity is updated to correspond with the model entity after execution.

xpressinsight.Column

Purpose
Represent a single column within a DataFrame entity.
Example
Example of declaring a column IntCol which will contain integer values. Note: this declaration should appear as part of a xpressinsight.DataFrame declaration.
>>> xi.Column("IntCol", dtype=xi.integer, alias="Input Integer Column")		
Related topics

xpressinsight.Column.__init__

Purpose
Initializes Column.
Synopsis
__init__(self, name: str, dtype: Type[xpressinsight.BasicType], alias: str = '', format: str = '', hidden: xpressinsight.Hidden = Hidden.FALSE, manage: xpressinsight.Manage = Manage.INPUT, read_only: bool = False, transform_labels_entity: str = '', update_after_execution: bool = False)
Arguments
name 
The name of the column.
dtype 
The data-type.
alias 
Used to provide an alternative name for an entity in the UI. The value is used in place of the entity name where appropriate in the UI.
format 
The formatting string used for displaying numeric values.
hidden 
Indicates whether the UI should hide the entity where appropriate.
manage 
How and whether Insight handles an entity. Defines how the system manages the entity data.
read_only 
Whether an entity is readonly. Specifies that the value(s) of the entity cannot be modified. See also hidden.
transform_labels_entity 
An entity in the schema to be used as a labels entity. The value is the name of the entity. The type of the index set of the labels entity much match the data type of this entity. The data type of the labels entity can be any primitive type.
update_after_execution 
Whether the value of the entity in the scenario is updated with the value of the corresponding model entity at the end of the scenario execution. If True the value of the entity is updated to correspond with the model entity after execution.

xpressinsight.DataFrame

Purpose
Represent a DataFrame entity.
Example
Example declaring a data-frame MixedTable which has three columns.
>>> MixedTable: xi.DataFrame(index='Years', columns=[
...     xi.Column("IntCol", dtype=xi.integer,
...               alias="Input Integer Column"),
...     xi.Column("StrCol", dtype=xi.string,
...               alias="Input String Column",
...               update_after_execution=True),
...     xi.Column("ResultCol", dtype=xi.real,
...               alias="Result Real Column",
...               manage=xi.Manage.RESULT)
... ])		
Related topics

xpressinsight.DataFrame.__init__

Purpose
Initializes DataFrame.
Synopsis
__init__(self, index: Union[str, List[str]], columns: Union[xpressinsight.Column, List[xpressinsight.Column]])
Arguments
index 
The index to use.
columns 
The columns which make up this data-frame.

xpressinsight.Manage

Purpose
How and whether Insight handles an entity.
Synopsis
class xi.Manage(Enum)
Arguments
xi.Manage.INPUT 
Included in the scenario input data.
xi.Manage.RESULT 
Included in the scenario results data.
Example
Manage a scalar entity as an input
>>> MyInteger: xi.Scalar(dtype=xi.integer,
...                      alias='My Integer',
...                      manage=xi.Manage.INPUT)		

xpressinsight.Hidden

Purpose
Possible values of whether the UI should hide an entity where appropriate.
Synopsis
class xi.Hidden(Enum)
Arguments
xi.Hidden.ALWAYS 
Indicates that the UI should hide the entity always.
xi.Hidden.TRUE 
Indicates that the UI should hide the entity where appropriate.
xi.Hidden.FALSE 
Indicates that the UI should show the entity where appropriate.
Example
Always hide an entity in the Insight UI
>>> MyInteger: xi.Scalar(dtype=xi.integer,
...                      alias='My Integer',
...                      hidden=xi.Hidden.ALWAYS)		

© 2001-2021 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.