IDAX.KNN - Build a KNN model

Use this stored procedure to build a k-Nearest Neighbors model.

Authorization

The privileges held by the authorization ID of the statement must include the IDAX_USER role.

Syntax

IDAX.KNN(in parameter_string varchar(32672))

Parameter descriptions

parameter_string
Mandatory one-string parameter that contains pairs of <parameter>=<value> entries that are separated by a comma.
Data type: VARCHAR(32672)
The following list shows the parameter values:
model
Mandatory.
The name of the KNN model that is to be built.
Data type: VARCHAR(64)
intable
Mandatory.
The name of the input table.
Data type: VARCHAR(128)
id
Mandatory.
The column of the input table that identifies a unique instance ID.
Data type: VARCHAR(128)
target
Mandatory.
The column of the input table that represents the prediction column.
Data type: VARCHAR(128)
incolumn
Optional.
The columns of the input table that have specific properties, which are separated by a semi-colon (;).
Each column is succeeded by one or more of the following properties:
  • By type nominal (":nom", ":nominal") or by type continuous (":cont", ":continuous"). By default, numerical types are continuous, and all other types are nominal.
  • By type nominal (:nom) or by type continuous (:cont). By default, numerical types are continuous, and all other types are nominal.
  • By role id (":id"), target (":target"), input (":active", ":in", ":input") or ignore (":ignore", ":inactive").
  • By role :id, :target, :input, or :ignore.
If this parameter is not specified, all columns of the input table have default properties.
Default: none
Data type: VARCHAR(32000)
coldeftype
Optional.
The default type of the columns of the input table.
Allowed values are nom and cont.
Allowed values are:
  • "nom" and "nominal" for type nominal
  • "cont" and "continuous" for type continuous
If the parameter is not specified, numeric columns are continuous, and all other columns are nominal.
Default: none
Data type: VARCHAR(4)
Data type: VARCHAR(10)
coldefrole
Optional.
The default role of the columns of the input table.
Allowed values are input and ignore.
Allowed values are:
  • "active", "in", and "input" for role input
  • "ignore" and "inactive" for role ignore
If the parameter is not specified, all columns are input columns.
Default: input
Data type: VARCHAR(8)
colPropertiesTable
Optional.
The input table where properties of the columns of the input table are stored.
The format of this table is the output format of the COLUMN_PROPERTIES() stored procedure.
Default: none
Data type: VARCHAR(128)
maxsize
Optional.
The maximum size of the sample of the input data that is stored in the model.
If the input data contains less than the maxsize records, the input data is stored in the model.
If the input data contains more than the maxsize records, sampling is done in one of the following ways:
  • If the target column is nominal, stratified sampling on the target column is done.
  • If the target column is numeric, a random sample of the input table is stored in the model.
Default: 10000
Minimum: 1
Data type: BIGINT
randseed
Optional.
The seed for the random number generator.
Default: 12345
Data type: INTEGER

Returned information

The number of input data records that are stored in the model as result set.

Example

CALL IDAX.KNN('model=customer_censor_mdl, intable=customer_churn, id=cust_id, target=censor');