本文整理汇总了Python中sklearn.neighbors.kde.KernelDensity.evaluate方法的典型用法代码示例。如果您正苦于以下问题:Python KernelDensity.evaluate方法的具体用法?Python KernelDensity.evaluate怎么用?Python KernelDensity.evaluate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.neighbors.kde.KernelDensity
的用法示例。
在下文中一共展示了KernelDensity.evaluate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_tdelt
# 需要导入模块: from sklearn.neighbors.kde import KernelDensity [as 别名]
# 或者: from sklearn.neighbors.kde.KernelDensity import evaluate [as 别名]
outputlist = inputlist/fac
except TypeError: #not an array
outputlist = [el/fac for el in inputlist]
return outputlist
isi = convert_tdelt(results['tau_valid'], units='minutes')
isi_hr = convert_tdelt(results['tau_valid'], units='hours')
tau_ax = np.arange(0,30*60,.2)
try:
from sklearn.neighbors.kde import KernelDensity
kern_type = 'epanechnikov'
kern_lab = '{0}{1} KDE'.format(kern_type[0].upper(), kern_type[1:])
kernel = KernelDensity(kernel=kern_type, bandwidth=60).fit(isi[:, np.newaxis])
kde_plot = np.exp(kernel.score_samples(tau_ax[:, np.newaxis]))
except ImportError:
from scipy import stats
kern_lab = 'Gaussian KDE'
kernel = stats.gaussian_kde(isi, bw_method='scott')
kde_plot = kernel.evaluate(tau_ax)
fig, ax = splot.set_target(None)
ax.hist(isi_hr, bins=np.arange(0,25,0.5), histtype='step', normed=True, lw=1.5, label='Binned Data')
ax.plot(tau_ax/60., kde_plot*60., lw=1.5, label=kern_lab)
ax.set_xlim([0,25])
ax.set_ylabel('Probability')
ax.set_xlabel(r'Inter-substorm Interval, $\tau$ [hours]') #raw string req'd (else \t in \tau becomes [tab]au
ax.legend()
fig.suptitle('MSM$_{Python}$: ' + '{0} (1998-2002)'.format(satname))
plt.show()