zhengruifeng commented on a change in pull request #27882: [SPARK-31127][ML]
Add abstract Selector
URL: https://github.com/apache/spark/pull/27882#discussion_r391397045
##########
File path:
mllib/src/main/scala/org/apache/spark/ml/feature/FValueSelector.scala
##########
@@ -344,57 +156,31 @@ class FValueSelectorModel private[ml](
@Since("3.1.0")
override def toString: String = {
- s"FValueSelectorModel: uid=$uid,
numSelectedFeatures=${selectedFeatures.length}"
- }
-
- private[spark] def compressSparse(
- indices: Array[Int],
- values: Array[Double]): (Array[Int], Array[Double]) = {
- val newValues = new ArrayBuilder.ofDouble
- val newIndices = new ArrayBuilder.ofInt
- var i = 0
- var j = 0
- var indicesIdx = 0
- var filterIndicesIdx = 0
- while (i < indices.length && j < selectedFeatures.length) {
- indicesIdx = indices(i)
- filterIndicesIdx = selectedFeatures(j)
- if (indicesIdx == filterIndicesIdx) {
- newIndices += j
- newValues += values(i)
- j += 1
- i += 1
- } else {
- if (indicesIdx > filterIndicesIdx) {
- j += 1
- } else {
- i += 1
- }
- }
- }
- // TODO: Sparse representation might be ineffective if (newSize ~=
newValues.size)
- (newIndices.result(), newValues.result())
+ s"FValueModel: uid=$uid, numSelectedFeatures=${selectedFeatures.length}"
}
}
@Since("3.1.0")
object FValueSelectorModel extends MLReadable[FValueSelectorModel] {
@Since("3.1.0")
- override def read: MLReader[FValueSelectorModel] =
- new FValueSelectorModelReader
+ override def read: MLReader[FValueSelectorModel] = new
FValueSelectorModelReader
@Since("3.1.0")
override def load(path: String): FValueSelectorModel = super.load(path)
private[FValueSelectorModel] class FValueSelectorModelWriter(
- instance: FValueSelectorModel) extends MLWriter {
+ instance:
+ FValueSelectorModel) extends MLWriter {
Review comment:
lint
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]