0 / 0
knnnode properties

knnnode properties

KNN node iconThe 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)
Table 1. knnnode properties
knnnode Properties Values Property description
analysis PredictTarget IdentifyNeighbors  
objective Balance Speed Accuracy Custom  
normalize_ranges flag  
use_case_labels flag Check box to enable next option.
case_labels_field field  
identify_focal_cases flag Check box to enable next option.
focal_cases_field field  
automatic_k_selection flag  
fixed_k integer Enabled only if automatic_k_selectio is False.
minimum_k integer Enabled only if automatic_k_selectio is True.
maximum_k integer  
distance_computation Euclidean CityBlock  
weight_by_importance flag  
range_predictions Mean Median  
perform_feature_selection flag  
forced_entry_inputs [field1 ... fieldN]  
stop_on_error_ratio flag  
number_to_select integer  
minimum_change number  
validation_fold_assign_by_field flag  
number_of_folds integer Enabled only if validation_fold_assign_by_field is False
set_random_seed flag  
random_seed number  
folds_field field Enabled only if validation_fold_assign_by_field is True
all_probabilities flag  
save_distances flag  
calculate_raw_propensities flag  
calculate_adjusted_propensities flag  
adjusted_propensity_partition Test Validation  
Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more