fit_knn: Fit K Nearest Neighbours to 'klassets_response_xy' object

View source: R/response_xy.R

fit_knnR Documentation

Fit K Nearest Neighbours to klassets_response_xy object

Description

Fit K Nearest Neighbours to klassets_response_xy object

Usage

fit_knn(df, neighbours = 10, type = "prob")

Arguments

df

A object from sim_response_xy.

neighbours

The neighbours parameter.

type

Type of prediction, one of prob or response.

Examples


set.seed(123)

df <- sim_response_xy(relationship = function(x, y) x**2 > sin(y))

plot(df)

# defaults to prob
fit_knn(df)

fit_knn(df, type = "response")

plot(fit_knn(df))

plot(fit_knn(df, neighbours = 3))

plot(fit_knn(df, neighbours = 10))

plot(fit_knn(df, neighbours = 200))

plot(fit_knn(df, neighbours = 3, type = "response"))

plot(fit_knn(df, neighbours = 10, type = "response"))

plot(fit_knn(df, neighbours = 200, type = "response"))


jbkunst/klassets documentation built on Dec. 7, 2022, 9:18 p.m.