aboutsummaryrefslogtreecommitdiff
path: root/examples/src/main/java/org/apache
diff options
context:
space:
mode:
authorYanbo Liang <ybliang8@gmail.com>2015-12-15 16:29:39 -0800
committerJoseph K. Bradley <joseph@databricks.com>2015-12-15 16:29:39 -0800
commitb24c12d7338b47b637698e7458ba90f34cba28c0 (patch)
tree2e88d1f095ebb49790401947ab611c6ace265fe7 /examples/src/main/java/org/apache
parentbc1ff9f4a41401599d3a87fb3c23a2078228a29b (diff)
downloadspark-b24c12d7338b47b637698e7458ba90f34cba28c0.tar.gz
spark-b24c12d7338b47b637698e7458ba90f34cba28c0.tar.bz2
spark-b24c12d7338b47b637698e7458ba90f34cba28c0.zip
[MINOR][ML] Rename weights to coefficients for examples/DeveloperApiExample
Rename ```weights``` to ```coefficients``` for examples/DeveloperApiExample. cc mengxr jkbradley Author: Yanbo Liang <ybliang8@gmail.com> Closes #10280 from yanboliang/spark-coefficients.
Diffstat (limited to 'examples/src/main/java/org/apache')
-rw-r--r--examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java b/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java
index 0b4c0d9ba9..b9dd3ad957 100644
--- a/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java
+++ b/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java
@@ -89,7 +89,7 @@ public class JavaDeveloperApiExample {
}
if (sumPredictions != 0.0) {
throw new Exception("MyJavaLogisticRegression predicted something other than 0," +
- " even though all weights are 0!");
+ " even though all coefficients are 0!");
}
jsc.stop();
@@ -149,12 +149,12 @@ class MyJavaLogisticRegression
// Extract columns from data using helper method.
JavaRDD<LabeledPoint> oldDataset = extractLabeledPoints(dataset).toJavaRDD();
- // Do learning to estimate the weight vector.
+ // Do learning to estimate the coefficients vector.
int numFeatures = oldDataset.take(1).get(0).features().size();
- Vector weights = Vectors.zeros(numFeatures); // Learning would happen here.
+ Vector coefficients = Vectors.zeros(numFeatures); // Learning would happen here.
// Create a model, and return it.
- return new MyJavaLogisticRegressionModel(uid(), weights).setParent(this);
+ return new MyJavaLogisticRegressionModel(uid(), coefficients).setParent(this);
}
@Override
@@ -173,12 +173,12 @@ class MyJavaLogisticRegression
class MyJavaLogisticRegressionModel
extends ClassificationModel<Vector, MyJavaLogisticRegressionModel> {
- private Vector weights_;
- public Vector weights() { return weights_; }
+ private Vector coefficients_;
+ public Vector coefficients() { return coefficients_; }
- public MyJavaLogisticRegressionModel(String uid, Vector weights) {
+ public MyJavaLogisticRegressionModel(String uid, Vector coefficients) {
this.uid_ = uid;
- this.weights_ = weights;
+ this.coefficients_ = coefficients;
}
private String uid_ = Identifiable$.MODULE$.randomUID("myJavaLogReg");
@@ -208,7 +208,7 @@ class MyJavaLogisticRegressionModel
* modifier.
*/
public Vector predictRaw(Vector features) {
- double margin = BLAS.dot(features, weights_);
+ double margin = BLAS.dot(features, coefficients_);
// There are 2 classes (binary classification), so we return a length-2 vector,
// where index i corresponds to class i (i = 0, 1).
return Vectors.dense(-margin, margin);
@@ -222,7 +222,7 @@ class MyJavaLogisticRegressionModel
/**
* Number of features the model was trained on.
*/
- public int numFeatures() { return weights_.size(); }
+ public int numFeatures() { return coefficients_.size(); }
/**
* Create a copy of the model.
@@ -235,7 +235,7 @@ class MyJavaLogisticRegressionModel
*/
@Override
public MyJavaLogisticRegressionModel copy(ParamMap extra) {
- return copyValues(new MyJavaLogisticRegressionModel(uid(), weights_), extra)
+ return copyValues(new MyJavaLogisticRegressionModel(uid(), coefficients_), extra)
.setParent(parent());
}
}