当前位置: 首页>>代码示例>>Python>>正文


Python KDEUnivariate.evaluate方法代码示例

本文整理汇总了Python中statsmodels.nonparametric.kde.KDEUnivariate.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python KDEUnivariate.evaluate方法的具体用法?Python KDEUnivariate.evaluate怎么用?Python KDEUnivariate.evaluate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在statsmodels.nonparametric.kde.KDEUnivariate的用法示例。


在下文中一共展示了KDEUnivariate.evaluate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pdf

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
    def pdf(self, token, years, bw=5, *args, **kwargs):

        """
        Estimate a density function from a token's ratio series.

        Args:
            token (str)
            years (iter)
            bw (int)

        Returns: OrderedDict {year: density}
        """

        series = self.clean_series(token, *args, **kwargs)

        # Use the ratio values as weights.
        weights = np.array(list(series.values()))

        # Fit the density estimate.
        density = KDEUnivariate(list(series.keys()))
        density.fit(fft=False, weights=weights, bw=bw)

        samples = OrderedDict()

        for year in years:
            samples[year] = density.evaluate(year)[0]

        return samples
开发者ID:davidmcclure,项目名称:history-of-literature,代码行数:30,代码来源:wpm_ratios.py

示例2: find_outiers_kde

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
def find_outiers_kde(x):
    x_scaled = scale(list(map(float,x)))
    kde = KDEUnivariate(x_scaled)
    kde.fit(bw="scott",fft=True)
    pred = kde.evaluate(x_scaled)
    
    n = sum(pred < 0.5)
    outlierindices=np.asarray(pred).argsort()[:n]
    outliervalue=np.asarray(x)[outlierindices]
    return outlierindices,outliervalue
开发者ID:banunitte,项目名称:WaterWave,代码行数:12,代码来源:Datapreprocessing.py

示例3: empiricalPDF

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
def empiricalPDF(data):
    """
    Evaluate a probability density function using kernel density
    estimation for input data.

    :param data: :class:`numpy.ndarray` of data values.

    :returns: PDF values at the data points.
    """
    LOG.debug("Calculating empirical PDF")
    sortedmax = np.sort(data)
    kde = KDEUnivariate(sortedmax)
    kde.fit()
    try:
        res = kde.evaluate(sortedmax)
    except MemoryError:
        res = np.zeros(len(sortedmax))
    return res
开发者ID:wcarthur,项目名称:extremes,代码行数:20,代码来源:distributions.py

示例4: kde_statsmodels_u

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
def kde_statsmodels_u(data, grid, **kwargs):
    """
    Univariate Kernel Density Estimation with Statsmodels

    Parameters
    ----------
    data : numpy.array
        Data points used to compute a density estimator. It
        has `n x 1` dimensions, representing n points and p
        variables.
    grid : numpy.array
        Data points at which the desity will be estimated. It
        has `m x 1` dimensions, representing m points and p
        variables.

    Returns
    -------
    out : numpy.array
        Density estimate. Has `m x 1` dimensions
    """
    kde = KDEUnivariate(data)
    kde.fit(**kwargs)
    return kde.evaluate(grid)
开发者ID:jwhendy,项目名称:plotnine,代码行数:25,代码来源:density.py

示例5: kde_statsmodels_u

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
def kde_statsmodels_u(x, x_grid, bandwidth=0.2, **kwargs):
    """Univariate Kernel Density Estimation with Statsmodels"""
    kde = KDEUnivariate(x)
    kde.fit(bw=bandwidth, **kwargs)
    return kde.evaluate(x_grid)
开发者ID:eddienko,项目名称:EuclidVisibleInstrument,代码行数:7,代码来源:analyseBackground.py

示例6:

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
        ])
    except AttributeError:
        # wtf this fails sometimes, idk, works on root6
        HAS_ROOT = False

##################################################################
# ... and plot everything.

fig, axes = plt.subplots(ncols=2, nrows=2, figsize=(6 * 2, 4 * 2))

axes[0, 0].hist(resid, bins='auto', normed=True)
axes[0, 0].plot(x, lg.pdf(x), label='Log Norm')
axes[0, 0].plot(x, hc.pdf(x), label='Half Cauchy')
if HAS_ROOT:
    axes[0, 0].plot(x, land, label='Landau', color='blue')
axes[0, 0].plot(x, dens.evaluate(x), label='KDE')
axes[0, 0].set_xlabel('x')
axes[0, 0].set_xlim(0, 0.3)
axes[0, 0].set_ylabel('PDF(x)')
axes[0, 0].legend()

axes[0, 1].hist(resid, bins='auto', normed=True)
axes[0, 1].plot(x, lg.pdf(x), label='Log Norm')
axes[0, 1].plot(x, hc.pdf(x), label='Half Cauchy')
if HAS_ROOT:
    axes[0, 1].plot(x, land, label='Landau', color='blue')
axes[0, 1].plot(x, dens.evaluate(x), label='KDE')
axes[0, 1].set_xlabel('x')
axes[0, 1].set_ylabel('PDF(x)')
axes[0, 1].set_yscale('log')
axes[0, 1].legend()
开发者ID:tamasgal,项目名称:km3pipe,代码行数:33,代码来源:guess_the_dist.py

示例7: kde_statsmodels_u

# 需要导入模块: from statsmodels.nonparametric.kde import KDEUnivariate [as 别名]
# 或者: from statsmodels.nonparametric.kde.KDEUnivariate import evaluate [as 别名]
 def kde_statsmodels_u(self, x_grid, bandwidth=0.2, **kwargs):
     """Univariate Kernel Density Estimation with Statsmodels"""
     from statsmodels.nonparametric.kde import KDEUnivariate
     kde = KDEUnivariate(self.data)
     kde.fit(bw=bandwidth, **kwargs)
     return kde.evaluate(x_grid)
开发者ID:WMGoBuffs,项目名称:biokit,代码行数:8,代码来源:kde.py


注:本文中的statsmodels.nonparametric.kde.KDEUnivariate.evaluate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。