<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def fit(self, X, y):
 """ Compute average slope and intercept for all X, y pairs Arguments: X (np.array):
 model input (independent variable) y (np.array):
 model output (dependent variable) Returns: Linear Regression instance with `slope` and `intercept` attributes References: Based on: https://github.com/justmarkham/DAT4/blob/master/notebooks/08_linear_regression.ipynb True True """


        # initial sums
        n = float(len(X))
        sum_x = X.sum()
        sum_y = y.sum()
        sum_xy = (X * y).sum()
        sum_xx = (X**2).sum()

        # formula for w0
        self.slope = (sum_xy - (sum_x * sum_y) / n) / (sum_xx - (sum_x * sum_x) / n)

        # formula for w1
        self.intercept = sum_y / n - self.slope * (sum_x / n)

        return self