diff options
author | MechCoder <manojkumarsivaraj334@gmail.com> | 2015-07-28 15:00:25 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2015-07-28 15:00:25 -0700 |
commit | 198d181dfb2c04102afe40680a4637d951e92c0b (patch) | |
tree | 2c04e7e9bc11c8f6e5bd998919f455f148b2277d /python/pyspark/mllib/util.py | |
parent | b88b868eb378bdb7459978842b5572a0b498f412 (diff) | |
download | spark-198d181dfb2c04102afe40680a4637d951e92c0b.tar.gz spark-198d181dfb2c04102afe40680a4637d951e92c0b.tar.bz2 spark-198d181dfb2c04102afe40680a4637d951e92c0b.zip |
[SPARK-7105] [PYSPARK] [MLLIB] Support model save/load in GMM
This PR introduces save / load for GMM's in python API.
Also I refactored `GaussianMixtureModel` and inherited it from `JavaModelWrapper` with model being `GaussianMixtureModelWrapper`, a wrapper which provides convenience methods to `GaussianMixtureModel` (due to serialization and deserialization issues) and I moved the creation of gaussians to the scala backend.
Author: MechCoder <manojkumarsivaraj334@gmail.com>
Closes #7617 from MechCoder/python_gmm_save_load and squashes the following commits:
9c305aa [MechCoder] [SPARK-7105] [PySpark] [MLlib] Support model save/load in GMM
Diffstat (limited to 'python/pyspark/mllib/util.py')
-rw-r--r-- | python/pyspark/mllib/util.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/python/pyspark/mllib/util.py b/python/pyspark/mllib/util.py index 875d3b2d64..916de2d6fc 100644 --- a/python/pyspark/mllib/util.py +++ b/python/pyspark/mllib/util.py @@ -21,7 +21,9 @@ import warnings if sys.version > '3': xrange = range + basestring = str +from pyspark import SparkContext from pyspark.mllib.common import callMLlibFunc, inherit_doc from pyspark.mllib.linalg import Vectors, SparseVector, _convert_to_vector @@ -223,6 +225,10 @@ class JavaSaveable(Saveable): """ def save(self, sc, path): + if not isinstance(sc, SparkContext): + raise TypeError("sc should be a SparkContext, got type %s" % type(sc)) + if not isinstance(path, basestring): + raise TypeError("path should be a basestring, got type %s" % type(path)) self._java_model.save(sc._jsc.sc(), path) |