Пример #1
0
 def run_linear_regression(self, x_axis, y_axis):
     self.x_axis = self.headers[x_axis]
     self.y_axis = self.headers[y_axis]
     self.slope = MathsUtil.estimate_slope(self.data[self.x_axis], self.data[self.y_axis])
     self.y_intercept = MathsUtil.estimate_y_intercept(self.data[self.x_axis], self.data[self.y_axis], self.slope)
     self.predicted_y = MathsUtil.num_plus_arr(self.y_intercept, MathsUtil.num_by_arr(self.slope, self.data[self.x_axis]))
 def test_number_plus_array(self):
     self.assertEqual(MathsUtil.num_plus_arr(0, [1, 2, 3]), [1, 2, 3])
     self.assertEqual(MathsUtil.num_plus_arr(2, [-1, -2, -3]), [1, 0, -1])
     self.assertEqual(MathsUtil.num_plus_arr(-1, [-1, -2, -3]), [-2, -3, -4])
     self.assertEqual(MathsUtil.num_plus_arr(2.5, [1.5, 2.4, 3.05]), [4, 4.9, 5.55])