def ssr_curve(self, x, y, slopes=[ 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 7.5, 10.0 ]): ssrs = [] for slope in slopes: yint = (np.mean(y) - slope * np.mean(x)) ssrs.append( self.get_ss_res(zip(x, y), lambda val: slope * val + yint)) image_manager = ImageManager() plotter = Plotter() plotter.set_title('Sum of Squared Residuals') plotter.set_axis_labels('Slope Selected', 'Sum of Squared Residual') plotter.set_output_filename(g.files['ls-ssr']) ssr_plot = ScatterSketch() ssr_plot.add_x(slopes) ssr_plot.add_y(ssrs) plotter.load(ssr_plot) plotter.save() plotter.close() g.debug.prn(self, 'Drawn Sum of Squared Residuals Plot') image_manager.scale(g.files['ls-ssr'], g.files['ls-ssr'], 250)
def gen_plot(): plotter.set_title(g.graph_titles['main']) g.x = g.randomizer.random_list(25, 0, 100) g.y = g.randomizer.random_list(25, 0, 100) # plotter.add_x_val(x) # [-2, -1, 0, 1, 2] # plotter.add_y_val(y) # [4,1,0,1,4] scatter = ScatterSketch() scatter.add_x(g.x) scatter.add_y(g.y) plotter.load(scatter) plotter.save() plotter.close() # g.modeller.gen_least_squares(x,y) # g.analyzer.f_dist(LinearModel, 100) image_manager.scale(g.files['plot'], g.files['plot'], g.image_height)