Sklearn KNN icon

Sklearn KNN

K-Nearest Neighbors classifier and regressor using scikit-learn

Actions2

Predict

AI-generated

Summary

Predict outcomes using a trained KNN model

Inputs

  • modelData (required) — JSON string containing the trained model
  • predictFeatureColumns (required) — Comma-separated list of feature column names
  • modelType — Classifier for classification or regressor for regression
  • pythonPath — Path to Python executable with scikit-learn installed

Output shape

A list of prediction objects

Each object includes a 'prediction' field; classifiers also include 'probabilities', and all objects include 'neighbor_distances' and 'neighbor_indices'

Examples

Example 1: Classify iris species

Model Type = classifier, Model Data = base64 JSON of trained classifier, Feature Columns = sepal length,sepal width,petal length,petal width

Example 2: Predict house prices

Model Type = regressor, Model Data = base64 JSON of trained regressor, Feature Columns = area,bedrooms,location

Example 3: Batch predict on multiple rows

Provide Model Data and Feature Columns; the node returns predictions for each input row

Discussion