# Copyright (C) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in project root for information.
import sys
if sys.version >= '3':
basestring = str
from pyspark.ml.param.shared import *
from pyspark import keyword_only
from pyspark.ml.util import JavaMLReadable, JavaMLWritable
from mmlspark.core.serialize.java_params_patch import *
from pyspark.ml.wrapper import JavaTransformer, JavaEstimator, JavaModel
from pyspark.ml.common import inherit_doc
from mmlspark.core.schema.Utils import *
[docs]@inherit_doc
class SummarizeData(ComplexParamsMixin, JavaMLReadable, JavaMLWritable, JavaTransformer):
"""
Args:
basic (bool): Compute basic statistics (default: true)
counts (bool): Compute count statistics (default: true)
errorThreshold (double): Threshold for quantiles - 0 is exact (default: 0.0)
percentiles (bool): Compute percentiles (default: true)
sample (bool): Compute sample statistics (default: true)
"""
@keyword_only
def __init__(self, basic=True, counts=True, errorThreshold=0.0, percentiles=True, sample=True):
super(SummarizeData, self).__init__()
self._java_obj = self._new_java_obj("com.microsoft.ml.spark.stages.SummarizeData")
self.basic = Param(self, "basic", "basic: Compute basic statistics (default: true)")
self._setDefault(basic=True)
self.counts = Param(self, "counts", "counts: Compute count statistics (default: true)")
self._setDefault(counts=True)
self.errorThreshold = Param(self, "errorThreshold", "errorThreshold: Threshold for quantiles - 0 is exact (default: 0.0)")
self._setDefault(errorThreshold=0.0)
self.percentiles = Param(self, "percentiles", "percentiles: Compute percentiles (default: true)")
self._setDefault(percentiles=True)
self.sample = Param(self, "sample", "sample: Compute sample statistics (default: true)")
self._setDefault(sample=True)
if hasattr(self, "_input_kwargs"):
kwargs = self._input_kwargs
else:
kwargs = self.__init__._input_kwargs
self.setParams(**kwargs)
[docs] @keyword_only
def setParams(self, basic=True, counts=True, errorThreshold=0.0, percentiles=True, sample=True):
"""
Set the (keyword only) parameters
Args:
basic (bool): Compute basic statistics (default: true)
counts (bool): Compute count statistics (default: true)
errorThreshold (double): Threshold for quantiles - 0 is exact (default: 0.0)
percentiles (bool): Compute percentiles (default: true)
sample (bool): Compute sample statistics (default: true)
"""
if hasattr(self, "_input_kwargs"):
kwargs = self._input_kwargs
else:
kwargs = self.__init__._input_kwargs
return self._set(**kwargs)
[docs] def setBasic(self, value):
"""
Args:
basic (bool): Compute basic statistics (default: true)
"""
self._set(basic=value)
return self
[docs] def getBasic(self):
"""
Returns:
bool: Compute basic statistics (default: true)
"""
return self.getOrDefault(self.basic)
[docs] def setCounts(self, value):
"""
Args:
counts (bool): Compute count statistics (default: true)
"""
self._set(counts=value)
return self
[docs] def getCounts(self):
"""
Returns:
bool: Compute count statistics (default: true)
"""
return self.getOrDefault(self.counts)
[docs] def setErrorThreshold(self, value):
"""
Args:
errorThreshold (double): Threshold for quantiles - 0 is exact (default: 0.0)
"""
self._set(errorThreshold=value)
return self
[docs] def getErrorThreshold(self):
"""
Returns:
double: Threshold for quantiles - 0 is exact (default: 0.0)
"""
return self.getOrDefault(self.errorThreshold)
[docs] def setPercentiles(self, value):
"""
Args:
percentiles (bool): Compute percentiles (default: true)
"""
self._set(percentiles=value)
return self
[docs] def getPercentiles(self):
"""
Returns:
bool: Compute percentiles (default: true)
"""
return self.getOrDefault(self.percentiles)
[docs] def setSample(self, value):
"""
Args:
sample (bool): Compute sample statistics (default: true)
"""
self._set(sample=value)
return self
[docs] def getSample(self):
"""
Returns:
bool: Compute sample statistics (default: true)
"""
return self.getOrDefault(self.sample)
[docs] @classmethod
def read(cls):
""" Returns an MLReader instance for this class. """
return JavaMMLReader(cls)
[docs] @staticmethod
def getJavaPackage():
""" Returns package name String. """
return "com.microsoft.ml.spark.stages.SummarizeData"
@staticmethod
def _from_java(java_stage):
module_name=SummarizeData.__module__
module_name=module_name.rsplit(".", 1)[0] + ".SummarizeData"
return from_java(java_stage, module_name)