Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/5137#discussion_r27335273
--- Diff: python/pyspark/mllib/classification.py ---
@@ -112,11 +122,47 @@ class
LogisticRegressionModel(LinearBinaryClassificationModel):
... os.removedirs(path)
... except:
... pass
+ >>> multi_class_data = [
+ ... LabeledPoint(0.0, [0.0, 1.0, 0.0]),
+ ... LabeledPoint(1.0, [1.0, 0.0, 0.0]),
+ ... LabeledPoint(2.0, [0.0, 0.0, 1.0])
+ ... ]
+ >>> mcm =
LogisticRegressionWithLBFGS.train(data=sc.parallelize(multi_class_data),
numClasses=3)
+ >>> mcm.predict([0.0, 0.5, 0.0])
+ 0
+ >>> mcm.predict([0.8, 0.0, 0.0])
+ 1
+ >>> mcm.predict([0.0, 0.0, 0.3])
+ 2
"""
- def __init__(self, weights, intercept):
+ def __init__(self, weights, intercept, numFeatures, numClasses):
super(LogisticRegressionModel, self).__init__(weights, intercept)
+ self._numFeatures = int(numFeatures)
+ self._numClasses = int(numClasses)
self._threshold = 0.5
+ @property
+ def numFeatures(self):
+ return self._numFeatures
+
+ @property
+ def numClasses(self):
+ return self._numClasses
+
+ @property
+ def dataWithBiasSize(self):
--- End diff --
I don't think we want to expose dataWithBiasSize or weightsMatrix. Can you
please define them in __init__ and add underscores in front of their names to
make it clear they are private?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]