Class/Object

org.apache.flink.ml.nn

KNN

Related Docs: object KNN | package nn

Permalink

class KNN extends Predictor[KNN]

Implements a k-nearest neighbor join.

Calculates the k-nearest neighbor points in the training set for each point in the test set.

Example:
  1. val trainingDS: DataSet[Vector] = ...
    val testingDS: DataSet[Vector] = ...
    val knn = KNN()
      .setK(10)
      .setBlocks(5)
      .setDistanceMetric(EuclideanDistanceMetric())
      knn.fit(trainingDS)
    val predictionDS: DataSet[(Vector, Array[Vector])] = knn.predict(testingDS)

    Parameters

    - org.apache.flink.ml.nn.KNN.K Sets the K which is the number of selected points as neighbors. (Default value: 5) - org.apache.flink.ml.nn.KNN.DistanceMetric Sets the distance metric we use to calculate the distance between two points. If no metric is specified, then org.apache.flink.ml.metrics.distances.EuclideanDistanceMetric is used. (Default value: EuclideanDistanceMetric()) - org.apache.flink.ml.nn.KNN.Blocks Sets the number of blocks into which the input data will be split. This number should be set at least to the degree of parallelism. If no value is specified, then the parallelism of the input DataSet is used as the number of blocks. (Default value: None) - org.apache.flink.ml.nn.KNN.UseQuadTree A boolean variable that whether or not to use a quadtree to partition the training set to potentially simplify the KNN search. If no value is specified, the code will automatically decide whether or not to use a quadtree. Use of a quadtree scales well with the number of training and testing points, though poorly with the dimension. (Default value: None) - org.apache.flink.ml.nn.KNN.SizeHint Specifies whether the training set or test set is small to optimize the cross product operation needed for the KNN search. If the training set is small this should be CrossHint.FIRST_IS_SMALL and set to CrossHint.SECOND_IS_SMALL if the test set is small. (Default value: None)

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. KNN
  2. Predictor
  3. Estimator
  4. WithParameters
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new KNN()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def evaluate[Testing, PredictionValue](testing: DataSet[Testing], evaluateParameters: ParameterMap = ParameterMap.Empty)(implicit evaluator: EvaluateDataSetOperation[KNN, Testing, PredictionValue]): DataSet[(PredictionValue, PredictionValue)]

    Permalink

    Evaluates the testing data by computing the prediction value and returning a pair of true label value and prediction value.

    Evaluates the testing data by computing the prediction value and returning a pair of true label value and prediction value. It is important that the implementation chooses a Testing type from which it can extract the true label value.

    Definition Classes
    Predictor
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def fit[Training](training: DataSet[Training], fitParameters: ParameterMap = ParameterMap.Empty)(implicit fitOperation: FitOperation[KNN, Training]): Unit

    Permalink

    Fits the estimator to the given input data.

    Fits the estimator to the given input data. The fitting logic is contained in the FitOperation. The computed state will be stored in the implementing class.

    Training

    Type of the training data

    training

    Training data

    fitParameters

    Additional parameters for the FitOperation

    fitOperation

    FitOperation which encapsulates the algorithm logic

    Definition Classes
    Estimator
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  17. val parameters: ParameterMap

    Permalink
    Definition Classes
    WithParameters
  18. def predict[Testing, Prediction](testing: DataSet[Testing], predictParameters: ParameterMap = ParameterMap.Empty)(implicit predictor: PredictDataSetOperation[KNN, Testing, Prediction]): DataSet[Prediction]

    Permalink

    Predict testing data according the learned model.

    Predict testing data according the learned model. The implementing class has to provide a corresponding implementation of PredictDataSetOperation which contains the prediction logic.

    Testing

    Type of the testing data

    Prediction

    Type of the prediction data

    testing

    Testing data which shall be predicted

    predictParameters

    Additional parameters for the prediction

    predictor

    PredictDataSetOperation which encapsulates the prediction logic

    Definition Classes
    Predictor
  19. def setBlocks(n: Int): KNN

    Permalink

    Sets the number of data blocks/partitions

    Sets the number of data blocks/partitions

    n

    the number of data blocks

  20. def setDistanceMetric(metric: DistanceMetric): KNN

    Permalink

    Sets the distance metric

    Sets the distance metric

    metric

    the distance metric to calculate distance between two points

  21. def setK(k: Int): KNN

    Permalink

    Sets K

    Sets K

    k

    the number of selected points as neighbors

  22. def setSizeHint(sizeHint: CrossHint): KNN

    Permalink

    Parameter a user can specify if one of the training or test sets are small

    Parameter a user can specify if one of the training or test sets are small

    sizeHint

    cross hint tells the system which sizes to expect from the data sets

  23. def setUseQuadTree(useQuadTree: Boolean): KNN

    Permalink

    Sets the Boolean variable that decides whether to use the QuadTree or not

  24. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  25. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  26. var trainingSet: Option[DataSet[Block[Vector]]]

    Permalink
  27. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Predictor[KNN]

Inherited from Estimator[KNN]

Inherited from WithParameters

Inherited from AnyRef

Inherited from Any

Ungrouped