Non-Parametric Models: KDEs
Derived Feature: x = |f0 – f1|/f0
Definition: the ratio of the submitted charge to the difference between the submitted charge and payment amount by medicare.
x = abs(f0-f1)/f0 n0, bins0, patches0=plt.hist(x,100,normed=0,range=(0,1),histtype='stepfilled') plt.setp(patches0, 'facecolor','g','alpha', 0.75) from scipy import stats from functools import partial def my_kde_bandwidth(obj, fac=1./5): """We use Scott's Rule, multiplied by a constant factor.""" return np.power(obj.n, -1./(obj.d+4)) * fac def getKDE(data, name="", bwfac = 0.2): x2 = data x_eval = np.linspace(x2.min() - 1, x2.max() + 1, 500) kde = stats.gaussian_kde(x2, bw_method=partial(my_kde_bandwidth, fac=bwfac)) fig1 = plt.figure(figsize=(8.6)) ax = fig1.add_subplot(111) plt.yscale=('log') plt.grid(True) x2h1, x2h2 = np.histogramix.bins=[0.,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0],normed ax.plot(x2, np.zeros(x2.shape), 'b+', ms=12)