pyspark.pandas.Series.plot.kde

plot. kde ( bw_method = None , ind = None , ** kwargs )

使用高斯核生成核密度估计图。

Parameters
bw_method scalar

用于计算估计器带宽的方法。 有关更多信息,请参阅 PySpark 中的 KernelDensity。

ind NumPy array or integer, optional

估计PDF的评估点。如果为None(默认),则使用1000个等间距的点。如果 ind 是NumPy数组,则在传递的点上评估KDE。如果 ind 是整数,则使用 ind 个等间距的点。

**kwargs optional

传递给 pandas-on-Spark.Series.plot() 的关键字参数。

Returns
plotly.graph_objs.Figure

backend!=plotly 时返回一个自定义对象。 当 subplots=True 时返回一个ndarray(仅限matplotlib)。

示例

应指定一个标量带宽。使用较小的带宽值可能会导致过拟合,而使用较大的带宽值可能会导致欠拟合:

>>> s = ps.Series([1, 2, 2.5, 3, 3.5, 4, 5])
>>> s.plot.kde(bw_method=0.3)  
>>> s = ps.Series([1, 2, 2.5, 3, 3.5, 4, 5])
>>> s.plot.kde(bw_method=3)  

参数 ind 决定了估计KDF图的评估点:

>>> s = ps.Series([1, 2, 2.5, 3, 3.5, 4, 5])
>>> s.plot.kde(ind=[1, 2, 3, 4, 5], bw_method=0.3)  

对于 DataFrame,它的工作方式与 Series 相同:

>>> df = ps.DataFrame({
...     'x': [1, 2, 2.5, 3, 3.5, 4, 5],
...     'y': [4, 4, 4.5, 5, 5.5, 6, 6],
... })
>>> df.plot.kde(bw_method=0.3)  
>>> df = ps.DataFrame({
...     'x': [1, 2, 2.5, 3, 3.5, 4, 5],
...     'y': [4, 4, 4.5, 5, 5.5, 6, 6],
... })
>>> df.plot.kde(bw_method=3)  
>>> df = ps.DataFrame({
...     'x': [1, 2, 2.5, 3, 3.5, 4, 5],
...     'y': [4, 4, 4.5, 5, 5.5, 6, 6],
... })
>>> df.plot.kde(ind=[1, 2, 3, 4, 5, 6], bw_method=0.3)