Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/15721#discussion_r93891859
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/util/MLTestingUtils.scala ---
@@ -182,34 +182,18 @@ object MLTestingUtils extends SparkFunSuite {
.toMap
}
- def genClassificationInstancesWithWeightedOutliers(
- spark: SparkSession,
- numClasses: Int,
- numInstances: Int): DataFrame = {
- val data = Array.tabulate[Instance](numInstances) { i =>
- val feature = i % numClasses
- if (i < numInstances / 3) {
- // give large weights to minority of data with 1 to 1 mapping
feature to label
- Instance(feature, 1.0, Vectors.dense(feature))
- } else {
- // give small weights to majority of data points with reverse
mapping
- Instance(numClasses - feature - 1, 0.01, Vectors.dense(feature))
- }
- }
- val labelMeta =
-
NominalAttribute.defaultAttr.withName("label").withNumValues(numClasses).toMetadata()
- spark.createDataFrame(data).select(col("label").as("label",
labelMeta), col("weight"),
- col("features"))
- }
-
+ /**
+ * Given a dataframe, generate two output dataframes: one having the
original rows oversampled
+ * an integer number of times, and one having the original rows but with
a column of weights
+ * proportional to the number of oversampled instances in the
oversampled dataframe.
+ */
def genEquivalentOversampledAndWeightedInstances(
--- End diff --
I made them all take `Dataset[LabeledPoint]`. Good suggestion.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]