| Did you know ... | Search Documentation: |
| Pack logtalk -- logtalk-3.100.1/docs/handbook/_sources/libraries/knn_regression.rst.txt |
.. _library_knn_regression:
knn_regressionk-Nearest Neighbors regressor supporting continuous and mixed-feature datasets. Learns lazily by storing encoded training rows and predicts targets as the weighted average of the k nearest neighbors.
The library implements the regressor_protocol defined in the
regression_protocols library, learns lazily by storing encoded
training rows, and predicts numeric targets using the weighted average
of the nearest encoded neighbors.
Open the `../../apis/library_index.html#knn_regression <../../apis/library_index.html#knn_regression>`__ link in a web browser.
To load this library, load the loader.lgt file:
::
| ?- logtalk_load(knn_regression(loader)).
To test this library predicates, load the tester.lgt file:
::
| ?- logtalk_load(knn_regression(tester)).
To run the performance benchmark suite, load the
tester_performance.lgt file:
::
| ?- logtalk_load(knn_regression(tester_performance)).
The learned regressor is represented by default as:
knn_regressor(Encoders, Rows, Diagnostics)
The exported predicate clauses therefore use the shape:Functor(Encoders, Rows, Diagnostics)
In this representation, Rows stores encoded feature vectors paired
with numeric targets and Diagnostics stores training metadata
including the effective options.The diagnostics/2 predicate returns a list of metadata terms with the form:
::
[
model(knn_regression),
target(Target),
training_example_count(TrainingExampleCount),
options(Options),
encoded_feature_count(FeatureCount)
]
Where:
model(knn_regression) identifies the learning algorithm that
produced the regressor.target(Target) stores the target attribute name declared by the
training dataset.training_example_count(TrainingExampleCount) stores the number of
examples used during training.options(Options) stores the effective learning options after
merging the user options with the library defaults.encoded_feature_count(FeatureCount) stores the number of numeric
features induced by the encoder list, including missing-value
indicator features.
Use the regression_protocols diagnostic/2 and
regressor_options/2 helper predicates when you only need a single
metadata term or the effective options.
The learn/3 predicate accepts the following options:
3.euclidean, manhattan,
chebyshev, and minkowski. The default is euclidean.uniform, distance, and
gaussian. The default is uniform.distance_metric(minkowski) is selected. Larger values increase the
influence of larger coordinate differences. The default is 3.0.true and false. The default is true.