@@ -89,7 +89,7 @@ public static void main(String[] args) throws Exception {
8989 }
9090 if (sumPredictions != 0.0 ) {
9191 throw new Exception ("MyJavaLogisticRegression predicted something other than 0," +
92- " even though all weights are 0!" );
92+ " even though all coefficients are 0!" );
9393 }
9494
9595 jsc .stop ();
@@ -149,12 +149,12 @@ public MyJavaLogisticRegressionModel train(DataFrame dataset) {
149149 // Extract columns from data using helper method.
150150 JavaRDD <LabeledPoint > oldDataset = extractLabeledPoints (dataset ).toJavaRDD ();
151151
152- // Do learning to estimate the weight vector.
152+ // Do learning to estimate the coefficients vector.
153153 int numFeatures = oldDataset .take (1 ).get (0 ).features ().size ();
154- Vector weights = Vectors .zeros (numFeatures ); // Learning would happen here.
154+ Vector coefficients = Vectors .zeros (numFeatures ); // Learning would happen here.
155155
156156 // Create a model, and return it.
157- return new MyJavaLogisticRegressionModel (uid (), weights ).setParent (this );
157+ return new MyJavaLogisticRegressionModel (uid (), coefficients ).setParent (this );
158158 }
159159
160160 @ Override
@@ -173,12 +173,12 @@ public MyJavaLogisticRegression copy(ParamMap extra) {
173173class MyJavaLogisticRegressionModel
174174 extends ClassificationModel <Vector , MyJavaLogisticRegressionModel > {
175175
176- private Vector weights_ ;
177- public Vector weights () { return weights_ ; }
176+ private Vector coefficients_ ;
177+ public Vector coefficients () { return coefficients_ ; }
178178
179- public MyJavaLogisticRegressionModel (String uid , Vector weights ) {
179+ public MyJavaLogisticRegressionModel (String uid , Vector coefficients ) {
180180 this .uid_ = uid ;
181- this .weights_ = weights ;
181+ this .coefficients_ = coefficients ;
182182 }
183183
184184 private String uid_ = Identifiable$ .MODULE$ .randomUID ("myJavaLogReg" );
@@ -208,7 +208,7 @@ public String uid() {
208208 * modifier.
209209 */
210210 public Vector predictRaw (Vector features ) {
211- double margin = BLAS .dot (features , weights_ );
211+ double margin = BLAS .dot (features , coefficients_ );
212212 // There are 2 classes (binary classification), so we return a length-2 vector,
213213 // where index i corresponds to class i (i = 0, 1).
214214 return Vectors .dense (-margin , margin );
@@ -222,7 +222,7 @@ public Vector predictRaw(Vector features) {
222222 /**
223223 * Number of features the model was trained on.
224224 */
225- public int numFeatures () { return weights_ .size (); }
225+ public int numFeatures () { return coefficients_ .size (); }
226226
227227 /**
228228 * Create a copy of the model.
@@ -235,7 +235,7 @@ public Vector predictRaw(Vector features) {
235235 */
236236 @ Override
237237 public MyJavaLogisticRegressionModel copy (ParamMap extra ) {
238- return copyValues (new MyJavaLogisticRegressionModel (uid (), weights_ ), extra )
238+ return copyValues (new MyJavaLogisticRegressionModel (uid (), coefficients_ ), extra )
239239 .setParent (parent ());
240240 }
241241}
0 commit comments