title: Large MSE and MAE in Linear Regression model
body: <p>I use <a href="https://i.stack.imgur.com/aMtDF.png" rel="nofollow noreferrer">this formula</a> to calculate weights and bias.
  This is my code:</p>
  <pre><code>def train(train_X, train_Y):
    X1 = np.insert(train_X, 1, 1, axis=1) # (50, 2)
    weight, bias = np.linalg.inv((X1.T).dot(X1)).dot((X1.T).dot(train_Y))
    return np.array([weight]), bias
  
  Y_train_predicted = X_train.dot(w) + b
  Y_test_predicted = X_test.dot(w) + b
  </code></pre>
  <p>And use MSE and MAE method to check predicted values:</p>
  <pre><code>def mse(true, pred):    
      return np.mean((true - pred)**2)
  
  def mae(true, pred):    
      return np.mean(np.abs(true - pred))
  </code></pre>
  <p>But my MSE value is over 100, meanwhile I read that in a good model it should strive to 1. And MAE value is over 1 which is also bad. However, the plot shows that predicted values are close to actual:</p>
  <p><a href="https://i.stack.imgur.com/Ba67x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ba67x.png" alt="enter image description here" /></a></p>
  <p>My training and test data:</p>
  <pre><code>def generate_data(n_points=20):
    X = np.linspace(-5, 5, n_points)
    y = 10 * X - 7
  
    X_train = X[0::2].reshape(-1, 1)
    y_train = y[0::2] + np.random.randn(int(n_points/2)) * 10
  
    X_test = X[1::2].reshape(-1, 1)
    y_test = y[1::2] + np.random.randn(int(n_points/2)) * 10
  
    print(f'Generated {len(X_train)} train samples and {len(X_test)} test samples')
    return X, X_train, y_train, X_test, y_test
  </code></pre>
  <p>How do MSE and MAE methods work? What did I do wrong? Why MSE value is not between 0 and 1?</p>