title: Encountering a vague RuntimeWarning when trying to plot a linear regression model using sk learn
body: <pre><code>import pandas
  import math
  from csv import reader
  import sys
  import numpy as np
  from pandas.plotting import scatter_matrix
  import matplotlib.pyplot as plt
  import scipy.optimize as opt
  import warnings
  from sklearn import model_selection
  from sklearn import linear_model  
  
  
  def fxn():
      warnings.warn("Runtime Warning",RuntimeWarning)
  
  with warnings.catch_warnings():
      warnings.simplefilter("ignore")
      fxn()
  def costcomp(X,y,theta):
      inner=np.power(((X*theta.T)-y),2)
      return np.sum(inner)/(2*len(X))
  
  
  def gradient(theta,X,y,lr,itr):
      temp=np.matrix(np.zeros(theta.shape))
      parameters=int(theta.ravel().shape[1])
      cost=np.zeros(itr)
      for i in range(itr):
          err=(X*theta.T)-y
          for j in range(parameters):
              tem=np.multiply(err,X[:,j])
              temp[0,j]=theta[0,j]-((lr/len(X))*np.sum(tem))
          theta=temp
          cost[i]=costcomp(X,y,theta)
  
      return theta,cost
  
  
  dataset = pandas.read_csv("PYTHONFINAL.csv",names=['Month','Year','Day','Time','SpeedLimit','Age','Accidents'])
  dataset = (dataset- dataset.mean()) / dataset.std()  
  dataset.insert(0, 'Ones', 1)
  
  cols=dataset.shape[1]
  X=dataset.iloc[:,0:cols-1]
  y=dataset.iloc[:,cols-1:cols]
  X = np.matrix(X.values)  
  y = np.matrix(y.values)
  theta = np.matrix(np.array([0,0,0,0,0,0,0]))
  X_train, X_validation, y_train, y_validation = model_selection.train_test_split(X, y, test_size=0.20, random_state=7)
  print(costcomp(X_train,y_train,theta))
  learningrate=0.01
  iterations=2000
  grad,costf=gradient(theta,X_train,y_train,learningrate,iterations)
  print(grad)
  print(costcomp(X_train,y_train,grad))
  fig, ax = plt.subplots(figsize=(12,8))  
  ax.plot(np.arange(iterations),costf, 'r')  
  ax.set_xlabel('Iterations')  
  ax.set_ylabel('Cost')  
  ax.set_title('Error vs. Training Epoch')
  
  #           **PROBLEM STARTS HERE**
  
  model = linear_model.LinearRegression()
  model.fit(X, y)
  x = np.array(X[:, 1].A1)  
  f = model.predict(X).flatten()
  
  plt.show()
  
  
  x = np.linspace(dataset.Month.min(), dataset.Month.max(), 100)  
  f = grad[0, 0] + (grad[0, 1] * x)
  
  fig, ax = plt.subplots(figsize=(12,8))  
  ax.plot(x, f, 'r', label='Prediction')  
  ax.scatter(dataset.Month, dataset.Accidents, label='Traning Data')  
  ax.legend(loc=2)  
  ax.set_xlabel('Month')  
  ax.set_ylabel('Accidents')  
  ax.set_title('Predicted Accidents vs. Month')  
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code>Warning (from warnings module):
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/scipy/linalg/basic.py", line 1226
      warnings.warn(mesg, RuntimeWarning)
  RuntimeWarning: internal gelsd driver lwork query error, required iwork dimension not returned. This is likely the result of LAPACK bug 0038, fixed in LAPACK 3.2.2 (released July 21, 2010). Falling back to 'gelss' driver.
  </code></pre>
  
  <p>PROBLEM:</p>
  
  <p>I have been wanting to plot a graph to see whether the linear regression model build is effective or not.Therefore,I want a regression line plot for the model i built and the original dataset used for this program.The head(20) values of dataset I have used is provided in the image attached.</p>
  
  <p><a href="https://i.stack.imgur.com/Swkwu.png" rel="nofollow noreferrer">Dataset for the problem</a></p>