Skip to content

Commit

Permalink
Minor][MLLIB] Format toString method in MLLIB
Browse files Browse the repository at this point in the history
Change to string interpolation way
  • Loading branch information
Alain committed Apr 25, 2015
1 parent bdc402f commit 44ba947
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ class SparseVector(
s" ${values.size} values.")

override def toString: String =
"(%s,%s,%s)".format(size, indices.mkString("[", ",", "]"), values.mkString("[", ",", "]"))
s"($size,${indices.mkString("[", ",", "]")},${values.mkString("[", ",", "]")})"

override def toArray: Array[Double] = {
val data = new Array[Double](size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.apache.spark.SparkException
@BeanInfo
case class LabeledPoint(label: Double, features: Vector) {
override def toString: String = {
"(%s,%s)".format(label, features)
s"($label,$features)"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class InformationGainStats(
val rightPredict: Predict) extends Serializable {

override def toString: String = {
"gain = %f, impurity = %f, left impurity = %f, right impurity = %f"
.format(gain, impurity, leftImpurity, rightImpurity)
s"gain = $gain, impurity = $impurity, left impurity = $leftImpurity, right impurity = $rightImpurity"
}

override def equals(o: Any): Boolean = o match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class Node (
var stats: Option[InformationGainStats]) extends Serializable with Logging {

override def toString: String = {
"id = " + id + ", isLeaf = " + isLeaf + ", predict = " + predict + ", " +
"impurity = " + impurity + ", split = " + split + ", stats = " + stats
s"id = $id, isLeaf = $isLeaf, predict = $predict, impurity = $impurity, " +
s"split = $split, stats = $stats"
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ case class Split(
categories: List[Double]) {

override def toString: String = {
"Feature = " + feature + ", threshold = " + threshold + ", featureType = " + featureType +
", categories = " + categories
s"Feature = $feature, threshold = $threshold, featureType = $featureType, " +
s"categories = $categories"
}
}

Expand Down

0 comments on commit 44ba947

Please sign in to comment.