HyukjinKwon commented on code in PR #47685:
URL: https://github.com/apache/spark/pull/47685#discussion_r1712849589
##########
python/pyspark/pandas/plot/core.py:
##########
@@ -464,22 +465,44 @@ def calc_min_max():
@staticmethod
def compute_kde(sdf, bw_method=None, ind=None):
- from pyspark.mllib.stat import KernelDensity
-
- # 'sdf' is a Spark DataFrame that selects one column.
-
- # Using RDD is slow so we might have to change it to Dataset based
implementation
- # once Spark has that implementation.
- sample = sdf.rdd.map(lambda x: float(x[0]))
- kd = KernelDensity()
- kd.setSample(sample)
-
- assert isinstance(bw_method, (int, float)), "'bw_method' must be set
as a scalar number."
+ # refers to org.apache.spark.mllib.stat.KernelDensity
+ assert bw_method is not None and isinstance(
+ bw_method, (int, float)
+ ), "'bw_method' must be set as a scalar number."
+
+ assert ind is not None, "'ind' must be a scalar array."
+
+ bandwidth = float(bw_method)
+ points = [float(i) for i in ind]
+ logStandardDeviationPlusHalfLog2Pi = math.log(bandwidth) + 0.5 *
math.log(2 * math.pi)
+
+ def normPdf(
Review Comment:
`normpdf`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]