You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/03/27 07:43:49 UTC
[GitHub] [spark] zhengruifeng edited a comment on issue #27978:
[SPARK-31127][ML] Implement abstract Selector
zhengruifeng edited a comment on issue #27978: [SPARK-31127][ML] Implement abstract Selector
URL: https://github.com/apache/spark/pull/27978#issuecomment-604859600
What about this plan?
1, adding a method to select features by `SelectionResult` in `object SelectionTestResult`:
```scala
private[ml] object SelectionTestResult {
def select(results: Array[SelectionTestResult], selectorType: String, other params: ...): Array[Int] (or Array[(SelectionTestResult, Int)])
}
```
2, moving transformation function into `object ChiSqSelectorModel`, and then reusing it in other classes
```scala
val newSize = selectedFeatures.length
val func = { vector: Vector =>
vector match {
case SparseVector(_, indices, values) =>
val (newIndices, newValues) = compressSparse(indices, values)
Vectors.sparse(newSize, newIndices, newValues)
case DenseVector(values) =>
Vectors.dense(selectedFeatures.map(values))
case other =>
throw new UnsupportedOperationException(
s"Only sparse and dense vectors are supported but got ${other.getClass}.")
}
}
```
In this way, there will be no breaking change
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org