diff options
author | sethah <seth.hendrickson16@gmail.com> | 2016-11-21 05:36:49 -0800 |
---|---|---|
committer | Yanbo Liang <ybliang8@gmail.com> | 2016-11-21 05:36:49 -0800 |
commit | e811fbf9ed131bccbc46f3c5701c4ff317222fd9 (patch) | |
tree | 36026581dec2887f946fe15ad50e92ee69c69395 /python/pyspark/ml/classification.py | |
parent | 658547974915ebcaae83e13e4c3bdf68d5426fda (diff) | |
download | spark-e811fbf9ed131bccbc46f3c5701c4ff317222fd9.tar.gz spark-e811fbf9ed131bccbc46f3c5701c4ff317222fd9.tar.bz2 spark-e811fbf9ed131bccbc46f3c5701c4ff317222fd9.zip |
[SPARK-18282][ML][PYSPARK] Add python clustering summaries for GMM and BKM
## What changes were proposed in this pull request?
Add model summary APIs for `GaussianMixtureModel` and `BisectingKMeansModel` in pyspark.
## How was this patch tested?
Unit tests.
Author: sethah <seth.hendrickson16@gmail.com>
Closes #15777 from sethah/pyspark_cluster_summaries.
Diffstat (limited to 'python/pyspark/ml/classification.py')
-rw-r--r-- | python/pyspark/ml/classification.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/python/pyspark/ml/classification.py b/python/pyspark/ml/classification.py index 56c8c62259..83e1e89347 100644 --- a/python/pyspark/ml/classification.py +++ b/python/pyspark/ml/classification.py @@ -309,13 +309,16 @@ class LogisticRegressionModel(JavaModel, JavaClassificationModel, JavaMLWritable @since("2.0.0") def summary(self): """ - Gets summary (e.g. residuals, mse, r-squared ) of model on - training set. An exception is thrown if - `trainingSummary is None`. + Gets summary (e.g. accuracy/precision/recall, objective history, total iterations) of model + trained on the training set. An exception is thrown if `trainingSummary is None`. """ - java_blrt_summary = self._call_java("summary") - # Note: Once multiclass is added, update this to return correct summary - return BinaryLogisticRegressionTrainingSummary(java_blrt_summary) + if self.hasSummary: + java_blrt_summary = self._call_java("summary") + # Note: Once multiclass is added, update this to return correct summary + return BinaryLogisticRegressionTrainingSummary(java_blrt_summary) + else: + raise RuntimeError("No training summary available for this %s" % + self.__class__.__name__) @property @since("2.0.0") |