hanaml.KNNRegressor {hana.ml.r}R Documentation

K-Nearest Neighbor(KNN) Regressor

Description

hanaml.KNNRegressor is an R wrapper for PAL KNN algorithm for regression.

Usage

hanaml.KNNRegressor(conn.context,
                   data = NULL,
                   key = NULL,
                   features = NULL,
                   label = NULL,
                   n.neighbors = NULL,
                   aggregate.type = NULL,
                   metric = NULL,
                   minkowski.power = NULL,
                   algorithm = NULL,
                   categorical.variable = NULL)

Arguments

conn.context

ConnectionContext
The connection to the SAP HANA system.

data

DataFrame
DataFrame containing the data.

key

character
Name of the ID column of data.

features

list of character, optional
Names of the feature columns. If features is not provided, it defaults to all non-ID, no-label columns.

label

character
Name of the column in data that specifies the dependent variable.

n.neighbors

integer, optional
Number of nearest neighbors.#' Defaults to 1.

aggregate.type

("uniform", "distance-weighted"), optional
Method used for averaging the values of the K-nearest neighbors. Defaults to 'distance-weighted'.

metric

("manhattan", "euclidean", "minkowski", "chebyshev"), optional
Ways to compute the distance between data points.

Defaults to 'euclidean'.

minkowski.power

double, optional
When 'Minkowski' is used for metric, this parameter controls the value of power. Defaults to 3.0.

algorithm

("brute-force", "kd-tree"), optional
Algorithm used to compute the nearest neighbors.

Defaults to 'brute-force'.

categorical.variable

character or list of characters, optional
Integer columns in the data table that should be treated as category variable.

Format

R6Class object.

Details

K-Nearest Neighbor (KNN) is a memory-based classification or regression method with no explicit training phase. For regression purpose, it assumes that instances should have similar values to their nearest neighbors.

Value

A "KNNRegressor" object.

See Also

hanaml.KNNRegressor

Examples

## Not run: 
Training data:

> df.train$Collect()
   ID X1   X2 X3 VALUE
1   0  2    1  A     1
2   1  3   10  A    10
3   2  3   10  B    10
4   3  3   10  C     1
5   4  1 1000  C     1
6   5  1 1000  A    10
7   6  1 1000  B    99
8   7  1  999  A    99
9   8  1  999  B    10
10  9  1 1000  C    10

knr <- hanaml.KNNRegressor(conn.context = conn, data = df.train, key = "ID",
                           features = c("X1", "X2", "X3"),
                           label = "VALUE", n.neighbors = 3,
                           aggregate.type = "uniform",
                           algorithm = "brute-force",
                           categorical.variable = c("X1"))

## End(Not run)

[Package hana.ml.r version 1.0.8 Index]