зеркало из https://github.com/microsoft/spark.git
Remove Java-specific constructor for Rating.
The scala constructor works for native type java types. Modify examples to match this.
This commit is contained in:
Родитель
6caec3f441
Коммит
e1a209f791
|
@ -39,9 +39,9 @@ public class JavaALS {
|
||||||
static class ParseRating extends Function<String, Rating> {
|
static class ParseRating extends Function<String, Rating> {
|
||||||
public Rating call(String line) {
|
public Rating call(String line) {
|
||||||
StringTokenizer tok = new StringTokenizer(line, ",");
|
StringTokenizer tok = new StringTokenizer(line, ",");
|
||||||
Integer x = Integer.parseInt(tok.nextToken());
|
int x = Integer.parseInt(tok.nextToken());
|
||||||
Integer y = Integer.parseInt(tok.nextToken());
|
int y = Integer.parseInt(tok.nextToken());
|
||||||
Double rating = Double.parseDouble(tok.nextToken());
|
double rating = Double.parseDouble(tok.nextToken());
|
||||||
return new Rating(x, y, rating);
|
return new Rating(x, y, rating);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
|
|
||||||
package spark.mllib.recommendation
|
package spark.mllib.recommendation
|
||||||
|
|
||||||
import java.lang.{Integer => JInt}
|
|
||||||
import java.lang.{Double => JDouble}
|
|
||||||
|
|
||||||
import scala.collection.mutable.{ArrayBuffer, BitSet}
|
import scala.collection.mutable.{ArrayBuffer, BitSet}
|
||||||
import scala.util.Random
|
import scala.util.Random
|
||||||
import scala.util.Sorting
|
import scala.util.Sorting
|
||||||
|
@ -58,13 +55,7 @@ private[recommendation] case class InLinkBlock(
|
||||||
/**
|
/**
|
||||||
* A more compact class to represent a rating than Tuple3[Int, Int, Double].
|
* A more compact class to represent a rating than Tuple3[Int, Int, Double].
|
||||||
*/
|
*/
|
||||||
case class Rating(val user: Int, val product: Int, val rating: Double) {
|
case class Rating(val user: Int, val product: Int, val rating: Double)
|
||||||
|
|
||||||
// Constructor to build a rating from java Integers and Doubles.
|
|
||||||
def this(user: JInt, product: JInt, rating: JDouble) = {
|
|
||||||
this(user.intValue(), product.intValue(), rating.doubleValue())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternating Least Squares matrix factorization.
|
* Alternating Least Squares matrix factorization.
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class JavaKMeansSuite implements Serializable {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite");
|
sc = new JavaSparkContext("local", "JavaKMeans");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class JavaALSSuite implements Serializable {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
sc = new JavaSparkContext("local", "JavaLogisticRegressionSuite");
|
sc = new JavaSparkContext("local", "JavaALS");
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
|
|
Загрузка…
Ссылка в новой задаче