Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CLN: revise comment
  • Loading branch information
facaiy committed Jul 13, 2017
commit 00a7ed82cee5a9f2eb5f819e1177f480d9cb8f58
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ final class OneVsRest @Since("1.4.0") (
val numClasses = MetadataUtils.getNumClasses(labelSchema).fold(computeNumClasses())(identity)
instr.logNumClasses(numClasses)

// SPARK-21306: cache weightCol if necessary
val weightColIsUsed = isDefined(weightCol) && $(weightCol).nonEmpty && {
getClassifier match {
case _: HasWeightCol => true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ class OneVsRestSuite extends SparkFunSuite with MLlibTestSparkContext with Defau
assert(output.schema.fieldNames.toSet === Set("label", "features", "prediction"))
}

test("SPARK-21306: OneVsRest should cache weightCol if necessary") {
test("SPARK-21306: OneVsRest should support setWeightCol") {
val dataset2 = dataset.withColumn("weight", lit(1))
val ova = new OneVsRest().setWeightCol("weight").setClassifier(new LogisticRegression())
// failed if weightCol is not cached.
val ovaModel = ova.fit(dataset2)
assert(ovaModel !== null)
}
Expand Down
1 change: 0 additions & 1 deletion python/pyspark/ml/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,6 @@ def _fit(self, dataset):

numClasses = int(dataset.agg({labelCol: "max"}).head()["max("+labelCol+")"]) + 1

# SPARK - 21306: cache weightCol if necessary
weightCol = None
if (self.isDefined(self.weightCol) and self.getWeightCol()):
if isinstance(classifier, HasWeightCol):
Expand Down