KnnRegressor class abstract
A class that performs regression basing on k nearest neighbours
algorithm
K nearest neighbours algorithm is an algorithm that is targeted to search
most similar labelled observations (number of these observations equals k
)
for the given unlabelled one.
In order to make a prediction, or rather to set a label for a given new
observation, labels of found k
observations are being summed up and
divided by k
.
To get a more precise result, one may use weighted average of found labels - the farther a found observation from the target one, the lower the weight of the observation is. To obtain these weights one may use a kernel function.
Constructors
- KnnRegressor(DataFrame fittingData, String targetName, int k, {KernelType kernel = KernelType.gaussian, Distance distance = Distance.euclidean, DType dtype = dTypeDefaultValue})
-
Parameters:
factory
- KnnRegressor.fromJson(String json)
-
Restores previously fitted regressor instance from the given
json
factory
Properties
- distanceType → Distance
-
A distance type that is used to measure a distance between two
observations
no setter
- dtype → DType
-
A type for all numeric values using by the
Predictor
no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- k → int
-
A number of nearest neighbours
no setter
- kernelType → KernelType
-
A kernel type
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- schemaVersion → int?
-
Contains a version of the current json schema
no setterinherited
-
targetNames
→ Iterable<
String> -
A collection of target column names of a dataset which was used to learn the ML
model
no setterinherited
Methods
-
assess(
DataFrame observations, MetricType metricType) → double -
Assesses model performance according to provided
metricType
inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
predict(
DataFrame testFeatures) → DataFrame -
Returns prediction, based on the learned coefficients
inherited
-
retrain(
DataFrame data) → KnnRegressor -
Re-runs the learning process on the new training
data
. The features, model algorithm, and hyperparameters remain the same.inherited -
saveAsJson(
String filePath) → Future< File> -
Saves a json-serializable map into a newly created file with the path
filePath
inherited -
toJson(
) → Map< String, dynamic> -
Returns a json-serializable map
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited