Skip to content

Commit

Permalink
Make getters final for consistency with other mllib code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelmer Kuperus committed Oct 23, 2021
1 parent fa103dc commit a0d41bf
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ private[conversion] trait VectorConverterParams extends HasInputCol with HasOutp
*
* @group param
*/
val outputType: Param[String] = new Param[String](this, "outputType", "type of vector to produce")
final val outputType: Param[String] = new Param[String](this, "outputType", "type of vector to produce")

/** @group getParam */
def getOutputType: String = $(outputType)
final def getOutputType: String = $(outputType)

setDefault(outputType -> "array<float>")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,53 +93,53 @@ private[knn] trait KnnModelParams extends Params with HasFeaturesCol with HasPre
*
* @group param
*/
val queryIdentifierCol = new Param[String](this, "queryIdentifierCol", "column name for the query identifier")
final val queryIdentifierCol = new Param[String](this, "queryIdentifierCol", "column name for the query identifier")

/** @group getParam */
def getQueryIdentifierCol: String = $(queryIdentifierCol)
final def getQueryIdentifierCol: String = $(queryIdentifierCol)

/**
* Param for the column name for the query partitions.
*
* @group param
*/
val queryPartitionsCol = new Param[String](this, "queryPartitionsCol", "column name for the query partitions")
final val queryPartitionsCol = new Param[String](this, "queryPartitionsCol", "column name for the query partitions")

/** @group getParam */
def getQueryPartitionsCol: String = $(queryPartitionsCol)
final def getQueryPartitionsCol: String = $(queryPartitionsCol)

/**
* Param for number of neighbors to find (> 0).
* Default: 5
*
* @group param
*/
val k = new IntParam(this, "k", "number of neighbors to find", ParamValidators.gt(0))
final val k = new IntParam(this, "k", "number of neighbors to find", ParamValidators.gt(0))

/** @group getParam */
def getK: Int = $(k)
final def getK: Int = $(k)

/**
* Param that indicates whether to not return the a candidate when it's identifier equals the query identifier
* Default: false
*
* @group param
*/
val excludeSelf = new BooleanParam(this, "excludeSelf", "whether to include the row identifier as a candidate neighbor")
final val excludeSelf = new BooleanParam(this, "excludeSelf", "whether to include the row identifier as a candidate neighbor")

/** @group getParam */
def getExcludeSelf: Boolean = $(excludeSelf)
final def getExcludeSelf: Boolean = $(excludeSelf)

/**
* Param for the threshold value for inclusion. -1 indicates no threshold
* Default: -1
*
* @group param
*/
val similarityThreshold = new DoubleParam(this, "similarityThreshold", "do not return neighbors further away than this distance")
final val similarityThreshold = new DoubleParam(this, "similarityThreshold", "do not return neighbors further away than this distance")

/** @group getParam */
def getSimilarityThreshold: Double = $(similarityThreshold)
final def getSimilarityThreshold: Double = $(similarityThreshold)

/**
* Param that specifies the number of index replicas to create when querying the index. More replicas means you can
Expand All @@ -148,21 +148,21 @@ private[knn] trait KnnModelParams extends Params with HasFeaturesCol with HasPre
*
* @group param
*/
val numReplicas = new IntParam(this, "numReplicas", "number of index replicas to create when querying")
final val numReplicas = new IntParam(this, "numReplicas", "number of index replicas to create when querying")

/** @group getParam */
def getNumReplicas: Int = $(numReplicas)
final def getNumReplicas: Int = $(numReplicas)

/**
* Param that specifies the number of threads to use.
* Default: number of processors available to the Java virtual machine
*
* @group param
*/
val parallelism = new IntParam(this, "parallelism", "number of threads to use")
final val parallelism = new IntParam(this, "parallelism", "number of threads to use")

/** @group getParam */
def getParallelism: Int = $(parallelism)
final def getParallelism: Int = $(parallelism)

/**
* Param for the output format to produce. One of "full", "minimal" Setting this to minimal is more efficient
Expand All @@ -172,10 +172,10 @@ private[knn] trait KnnModelParams extends Params with HasFeaturesCol with HasPre
*
* @group param
*/
val outputFormat = new Param[String](this, "outputFormat", "output format to produce")
final val outputFormat = new Param[String](this, "outputFormat", "output format to produce")

/** @group getParam */
def getOutputFormat: String = $(outputFormat)
final def getOutputFormat: String = $(outputFormat)

setDefault(k -> 5, predictionCol -> "prediction", featuresCol -> "features",
excludeSelf -> false, similarityThreshold -> -1, outputFormat -> "full")
Expand Down Expand Up @@ -213,19 +213,19 @@ private[knn] trait KnnAlgorithmParams extends KnnModelParams {
*
* @group param
*/
val identifierCol = new Param[String](this, "identifierCol", "column name for the row identifier")
final val identifierCol = new Param[String](this, "identifierCol", "column name for the row identifier")

/** @group getParam */
def getIdentifierCol: String = $(identifierCol)
final def getIdentifierCol: String = $(identifierCol)

/**
* Number of partitions (default: 1)
*/
val numPartitions = new IntParam(this, "numPartitions",
final val numPartitions = new IntParam(this, "numPartitions",
"number of partitions", ParamValidators.gt(0))

/** @group getParam */
def getNumPartitions: Int = $(numPartitions)
final def getNumPartitions: Int = $(numPartitions)

/**
* Param for the distance function to use. One of "bray-curtis", "canberra", "cosine", "correlation", "euclidean",
Expand All @@ -234,15 +234,15 @@ private[knn] trait KnnAlgorithmParams extends KnnModelParams {
*
* @group param
*/
val distanceFunction = new Param[String](this, "distanceFunction", "distance function to use")
final val distanceFunction = new Param[String](this, "distanceFunction", "distance function to use")

/** @group getParam */
def getDistanceFunction: String = $(distanceFunction)
final def getDistanceFunction: String = $(distanceFunction)

val partitionCol = new Param[String](this, "partitionCol", "column name for the partition identifier")
final val partitionCol = new Param[String](this, "partitionCol", "column name for the partition identifier")

/** @group getParam */
def getPartitionCol: String = $(partitionCol)
final def getPartitionCol: String = $(partitionCol)

setDefault(identifierCol -> "id", distanceFunction -> "cosine", numPartitions -> 1, numReplicas -> 0)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,35 @@ class KnnSimilarityEvaluator(override val uid: String) extends Evaluator with De
*
* @group param
*/
val approximateNeighborsCol = new Param[String](this, "approximateNeighborsCol", "column containing the approximate neighbors")
final val approximateNeighborsCol = new Param[String](this, "approximateNeighborsCol", "column containing the approximate neighbors")

/**
* @group getParam
*/
def getApproximateNeighborsCol: String = $(approximateNeighborsCol)
final def getApproximateNeighborsCol: String = $(approximateNeighborsCol)

/**
* @group setParam
*/
def setApproximateNeighborsCol(value: String): this.type = set(approximateNeighborsCol, value)
final def setApproximateNeighborsCol(value: String): this.type = set(approximateNeighborsCol, value)

/**
* Param for the column name for the exact results.
* Default: "exactNeighbors"
*
* @group param
*/
val exactNeighborsCol = new Param[String](this, "exactNeighborsCol", "column containing the exact neighbors")
final val exactNeighborsCol = new Param[String](this, "exactNeighborsCol", "column containing the exact neighbors")

/**
* @group getParam
*/
def getExactNeighborsCol: String = $(exactNeighborsCol)
final def getExactNeighborsCol: String = $(exactNeighborsCol)

/**
* @group setParam
*/
def setExactNeighborsCol(value: String): this.type = set(exactNeighborsCol, value)
final def setExactNeighborsCol(value: String): this.type = set(exactNeighborsCol, value)

/**
* Returns the accuracy of the approximate results.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ private[hnsw] trait HnswParams extends KnnAlgorithmParams with HnswModelParams {
*
* @group param
*/
val m = new IntParam(this, "m",
final val m = new IntParam(this, "m",
"number of bi-directional links created for every new element during construction", ParamValidators.gt(0))

/** @group getParam */
def getM: Int = $(m)
final def getM: Int = $(m)

/**
* Has the same meaning as ef, but controls the index time / index precision.
* Default: 200
*
* @group param
*/
val efConstruction = new IntParam(this, "efConstruction",
final val efConstruction = new IntParam(this, "efConstruction",
"has the same meaning as ef, but controls the index time / index precision", ParamValidators.gt(0))

/** @group getParam */
def getEfConstruction: Int = $(efConstruction)
final def getEfConstruction: Int = $(efConstruction)

setDefault(m -> 16, efConstruction -> 200)
}
Expand All @@ -55,11 +55,11 @@ private[hnsw] trait HnswModelParams extends KnnModelParams {
*
* @group param
*/
val ef = new IntParam(this, "ef",
final val ef = new IntParam(this, "ef",
"size of the dynamic list for the nearest neighbors (used during the search)", ParamValidators.gt(0))

/** @group getParam */
def getEf: Int = $(ef)
final def getEf: Int = $(ef)

setDefault(ef -> 10)
}
Expand Down

0 comments on commit a0d41bf

Please sign in to comment.