M
- Model type.public abstract class KNNTrainer<M extends KNNModel<Double>,Self extends KNNTrainer<M,Self>> extends SingleLabelDatasetTrainer<M>
Dataset
that consists of a set of resources allocated across the cluster.DatasetTrainer.EmptyDatasetException
Modifier and Type | Field and Description |
---|---|
protected DistanceMeasure |
distanceMeasure
Distance measure.
|
protected int |
k
Number of neighbours.
|
protected boolean |
weighted
Weighted or not.
|
envBuilder, environment
Constructor and Description |
---|
KNNTrainer() |
Modifier and Type | Method and Description |
---|---|
protected abstract M |
convertDatasetIntoModel(Dataset<EmptyContext,SpatialIndex<Double>> dataset)
Convers given dataset into KNN model (classification or regression depends on implementation).
|
protected <K,V> M |
fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder,
Preprocessor<K,V> preprocessor)
Trains model based on the specified data.
|
boolean |
isUpdateable(M mdl) |
protected abstract Self |
self()
Returns
this instance. |
protected <K,V> M |
updateModel(M mdl,
DatasetBuilder<K,V> datasetBuilder,
Preprocessor<K,V> preprocessor)
Trains new model taken previous one as a first approximation.
|
Self |
withDataTtl(long dataTtl)
Sets up
dataTtl parameter. |
Self |
withDistanceMeasure(DistanceMeasure distanceMeasure)
Sets up
distanceMeasure parameter. |
Self |
withIdxType(SpatialIndexType idxType)
Sets up
idxType parameter. |
Self |
withK(int k)
Sets up
k parameter (number of neighbours). |
Self |
withWeighted(boolean weighted)
Sets up
weighted parameter. |
fit, fit, fit, fit, fit, fit, getLastTrainedModelOrThrowEmptyDatasetException, identityTrainer, learningEnvironment, update, update, update, update, update, withConvertedLabels, withEnvironmentBuilder
protected DistanceMeasure distanceMeasure
protected int k
protected boolean weighted
protected <K,V> M fitWithInitializedDeployingContext(DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)
fitWithInitializedDeployingContext
in class DatasetTrainer<M extends KNNModel<Double>,Double>
K
- Type of a key in upstream
data.V
- Type of a value in upstream
data.datasetBuilder
- Dataset builder.preprocessor
- Extractor of UpstreamEntry
into LabeledVector
.public boolean isUpdateable(M mdl)
isUpdateable
in class DatasetTrainer<M extends KNNModel<Double>,Double>
mdl
- Model.protected <K,V> M updateModel(M mdl, DatasetBuilder<K,V> datasetBuilder, Preprocessor<K,V> preprocessor)
updateModel
in class DatasetTrainer<M extends KNNModel<Double>,Double>
K
- Type of a key in upstream
data.V
- Type of a value in upstream
data.mdl
- Learned model.datasetBuilder
- Dataset builder.preprocessor
- Extractor of UpstreamEntry
into LabeledVector
.protected abstract M convertDatasetIntoModel(Dataset<EmptyContext,SpatialIndex<Double>> dataset)
dataset
- Dataset of spatial indices.protected abstract Self self()
this
instance.public Self withIdxType(SpatialIndexType idxType)
idxType
parameter.idxType
- Index type.public Self withDataTtl(long dataTtl)
dataTtl
parameter.dataTtl
- Partition data time-to-live in seconds (-1 for an infinite lifetime).public Self withDistanceMeasure(DistanceMeasure distanceMeasure)
distanceMeasure
parameter.distanceMeasure
- Distance measure.public Self withK(int k)
k
parameter (number of neighbours).k
- Number of neighbours.public Self withWeighted(boolean weighted)
weighted
parameter.weighted
- Weighted or not.
GridGain In-Memory Computing Platform : ver. 8.9.15 Release Date : December 3 2024