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


Python smoothers_lowess.lowess方法代码示例

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


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

示例1: plot_residuals

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def plot_residuals(residual, fitted, basename, outdir=None, scale=True):
	import matplotlib.pyplot as plt
	from statsmodels.nonparametric.smoothers_lowess import lowess

	if scale:
		residual = scalearr(residual)
		fitted = scalearr(fitted)

	fig, ax = plt.subplots()
	ax.scatter(fitted, residual)

	ys = lowess(residual, fitted)[:,1]
	ax.plot(np.sort(fitted), ys, 'r--')
	ax.set(xlabel='Fitted values', ylabel='Residuals', title=basename)
	ax.axhline(0, color='black', linestyle=':')
	if outdir is not None:
		fig.savefig("%s/resid_plot_%s.png" % (outdir, basename))
	else:
		fig.savefig("resid_plot_%s.png" % basename)
	plt.clf() 
开发者ID:trislett,项目名称:TFCE_mediation,代码行数:22,代码来源:tm_massunivariatemodels.py

示例2: calculate_engine_temperature_derivatives

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def calculate_engine_temperature_derivatives(
        times, engine_coolant_temperatures):
    """
    Calculates the derivative of the engine temperature [°C/s].

    :param times:
        Time vector [s].
    :type times: numpy.array

    :param engine_coolant_temperatures:
        Engine coolant temperature vector [°C].
    :type engine_coolant_temperatures: numpy.array

    :return:
        Derivative of the engine temperature [°C/s].
    :rtype: numpy.array
    """
    from statsmodels.nonparametric.smoothers_lowess import lowess
    par = dfl.functions.calculate_engine_temperature_derivatives
    temp = lowess(
        engine_coolant_temperatures, times, is_sorted=True,
        frac=par.tw * len(times) / (times[-1] - times[0]) ** 2, missing='none'
    )[:, 1].ravel()
    return _derivative(times, temp) 
开发者ID:JRCSTU,项目名称:CO2MPAS-TA,代码行数:26,代码来源:thermal.py

示例3: add_lowess

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def add_lowess(ax, lines_idx=0, frac=.2, **lowess_kwargs):
    """
    Add Lowess line to a plot.

    Parameters
    ----------
    ax : matplotlib Axes instance
        The Axes to which to add the plot
    lines_idx : int
        This is the line on the existing plot to which you want to add
        a smoothed lowess line.
    frac : float
        The fraction of the points to use when doing the lowess fit.
    lowess_kwargs
        Additional keyword arguments are passes to lowess.

    Returns
    -------
    fig : matplotlib Figure instance
        The figure that holds the instance.
    """
    y0 = ax.get_lines()[lines_idx]._y
    x0 = ax.get_lines()[lines_idx]._x
    lres = lowess(y0, x0, frac=frac, **lowess_kwargs)
    ax.plot(lres[:, 0], lres[:, 1], 'r', lw=1.5)
    return ax.figure 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:28,代码来源:regressionplots.py

示例4: test_import

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def test_import(self):
        #this doesn't work
        #from statsmodels.api.nonparametric import lowess as lowess1
        import statsmodels.api as sm
        lowess1 = sm.nonparametric.lowess
        assert_(lowess is lowess1) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:test_lowess.py

示例5: test_flat

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def test_flat(self):
        test_data = {
            'x': np.arange(20), 'y': np.zeros(20), 'out': np.zeros(20)}
        expected_lowess = np.array([test_data['x'], test_data['out']]).T
        actual_lowess = lowess(test_data['y'], test_data['x'])
        assert_almost_equal(expected_lowess, actual_lowess, 7) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:test_lowess.py

示例6: test_range

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def test_range(self):
        test_data = {
            'x': np.arange(20), 'y': np.arange(20), 'out': np.arange(20)}
        expected_lowess = np.array([test_data['x'], test_data['out']]).T
        actual_lowess = lowess(test_data['y'], test_data['x'])
        assert_almost_equal(expected_lowess, actual_lowess, 7) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:test_lowess.py

示例7: generate

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def generate(name, fname, x='x', y='y', out='out', kwargs=None, decimal=7):
        kwargs = {} if kwargs is None else kwargs
        data = np.genfromtxt(os.path.join(rpath, fname), delimiter=',', names=True)
        assert_almost_equal.description = name
        if callable(kwargs):
            kwargs = kwargs(data)
        result = lowess(data[y], data[x], **kwargs)
        expect = np.array([data[x], data[out]]).T
        assert_almost_equal(result, expect, decimal)

    # TODO: Refactor as parameterized test once nose is permanently dropped 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:13,代码来源:test_lowess.py

示例8: plot_doppler

# 需要导入模块: from statsmodels.nonparametric import smoothers_lowess [as 别名]
# 或者: from statsmodels.nonparametric.smoothers_lowess import lowess [as 别名]
def plot_doppler(x, tx_carrier_freq, beacon_carrier_freq):
    # Doppler
    plt.figure()
    
    dop1 = (tx_carrier_freq[:, 0] - tx_carrier_freq[:, 1])
    dop2 = (beacon_carrier_freq[:, 0] -
            beacon_carrier_freq[:, 1])
    dop_bin = (dop1 - dop2) / 2.0
    # 50 km/h doppler = 433e6 * ((3e8 + 50/3.6) / 3e8 - 1)
    #                 = 50/3.6 / 3e8 * 433e6
    hz_per_bin = 2.4e6 / 16384
    dop = dop_bin * hz_per_bin * 3e8 / 433e6 * 3.6
    dop_outliers = is_outlier(dop)

    dopx = x[~dop_outliers]

    dop_smooth = lowess(dop[~dop_outliers], dopx,
                        is_sorted=True, frac=0.025, it=0)

    plt.plot(dopx, dop[~dop_outliers], 'r', linewidth=0.2, alpha=0.5)
    plt.plot(dop_smooth[:, 0], dop_smooth[:, 1], 'b')
    plt.ylabel('Doppler shift (km/h)')
    plt.xlabel('TX timestamp at RX0 (s)')
    plt.grid()
    plt.tight_layout()
    # plt.show() 
开发者ID:swkrueger,项目名称:Thrifty,代码行数:28,代码来源:reldist_nearest.py


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