def kde(): import pyqt_fit.kernel_smoothing as smooth import data ''' Which data? ''' y = np.array(data.hubbert) x = np.array([x for x in range(1,len(y)+1)]) x = [xi/float(max(x)) for xi in x] y = [yi/float(max(y)) for yi in y] print "Data:", x, y estimator = smooth.SpatialAverage(x, y) estimate = estimator.evaluate(x) astar = AStar(x, y, .01, 50, False) best = astar.min besty = gen_data.get_y_data(best.exptree, best.fit_consts, x) print "MSE of kernel smoothing estimation: ", mse(y, estimate) print "MSE of function-space greedy search: ", mse(y, besty) plt.scatter(x, y, color='b') plt.hold(True) plt.plot(x, estimate, color='g') plt.plot(x, besty, color='r') plt.show()
def real_data(): import data ''' Which data to use: ''' y = data.oscillator x = [x for x in range(1,len(y)+1)] x = [xi/float(max(x)) for xi in x] y = [yi/float(max(y)) for yi in y] astar = AStar(x, y, 10, 50, False) best = astar.min besty = gen_data.get_y_data(best.exptree, best.fit_consts, x) plt.scatter(x, y) plt.hold(True) plt.plot(besty) plt.show()