About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
Last updated: Feb 11, 2025
The k-Nearest Neighbor (KNN) node associates a new case with the category
or value of the k objects nearest to it in the predictor space, where k is an integer.
Similar cases are near each other and dissimilar cases are distant from each other.
Example
node = stream.create("knn", "My node")
# Objectives tab
node.setPropertyValue("objective", "Custom")
# Settings tab - Neighbors panel
node.setPropertyValue("automatic_k_selection", False)
node.setPropertyValue("fixed_k", 2)
node.setPropertyValue("weight_by_importance", True)
# Settings tab - Analyze panel
node.setPropertyValue("save_distances", True)
Properties |
Values | Property description |
---|---|---|
|
|
|
|
|
|
|
flag | |
|
flag | Check box to enable next option. |
|
field | |
|
flag | Check box to enable next option. |
|
field | |
|
flag | |
|
integer | Enabled only if is . |
|
integer | Enabled only if is . |
|
integer | |
|
|
|
|
flag | |
|
|
|
|
flag | |
|
[field1 ... fieldN] | |
|
flag | |
|
integer | |
|
number | |
|
flag | |
|
integer | Enabled only if is
|
|
flag | |
|
number | |
|
field | Enabled only if is
|
|
flag | |
|
flag | |
|
flag | |
|
flag | |
|
|
Was the topic helpful?
0/1000