RECENGINE Procedure

KNN Statement

  • KNN <options>;

The KNN statement specifies the parameters of the sparse k-nearest neighbors method.

You can specify the following options:

DISTANCEMETRIC=COSINE | DICE

specifies the distance metric to be used during a KNN search. You can specify the following values:

COSINE

uses the cosine similarity measure during a KNN search.

DICE

uses the Dice similarity measure during a KNN search.

By default, DISTANCEMETRIC= COSINE.

K=number

specifies the number of neighbors in a KNN search.

MEMORYEFFICIENT

specifies that the model should use memory efficient hashing structures during a KNN search.

OUTSIMILARITY=libref.data-table

specifies the name of the output table to save the nearest-neighbor similarity scores to. libref.data-table is a two-level name, where libref refers to the library, and data-table specifies the name of the output data table. For more information about this two-level name, see the DATA= option and the section Using CAS Sessions and CAS Engine Librefs.

Last updated: August 06, 2026