title: Error using sklearn and linear regression: shapes (1,16) and (1,1) not aligned: 16 (dim 1) != 1 (dim 0)
body: <p>I wanted to learn about machine learning and I stumbled upon youtube siraj and his Udacity videos and wanted to try and pick up a few things.</p>
  <p>His video in reference: <a href="https://www.youtube.com/watch?v=vOppzHpvTiQ&amp;index=1&amp;list=PL2-dafEMk2A7YdKv4XfKpfbTH5z6rEEj3" rel="nofollow noreferrer">https://www.youtube.com/watch?v=vOppzHpvTiQ&amp;index=1&amp;list=PL2-dafEMk2A7YdKv4XfKpfbTH5z6rEEj3</a></p>
  <p>In his video, he had a txt file he imported and read, but when I tried to recreate the the txt file it couldn't be read correctly. Instead, I tried to create a pandas dataframe with the same data and perform the linear regression/predict on it, but then I got the below error.</p>
  <p>Found input variables with inconsistent numbers of samples: [1, 16] and something about passing 1d arrays and I need to reshape them.</p>
  <p>Then when I tried to reshape them following this post: <a href="https://stackoverflow.com/questions/44181664/sklearn-valueerror-found-input-variables-with-inconsistent-numbers-of-samples">Sklearn : ValueError: Found input variables with inconsistent numbers of samples: [1, 6]</a></p>
  <p>I get this error....</p>
  <p><strong>shapes (1,16) and (1,1) not aligned: 16 (dim 1) != 1 (dim 0)</strong></p>
  <p>This is my code down below. I know it's probably a syntax error, I'm just not familiar with this scklearn yet and would like some help.</p>
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  import numpy as np
  from sklearn import linear_model
  
  #DF = pd.read_fwf('BrainBodyWeight.txt')
  DF = pd.DataFrame()
  DF['Brain'] = [3.385, .480, 1.350, 465.00,36.330, 27.660, 14.830, 1.040, 4.190, 0.425, 0.101, 0.920, 1.000, 0.005, 0.060, 3.500 ]
  
  DF['Body'] = [44.500, 15.5, 8.1, 423, 119.5, 115, 98.2, 5.5,58, 6.40, 4, 5.7,6.6, .140,1, 10.8]
  
  try:
      x = DF['Brain']
      y = DF['Body']
  
      x = x.tolist()
      y = y.tolist()
  
      x = np.asarray(x)
      y = np.asarray(y)
  
  
      body_reg = linear_model.LinearRegression()
      body_reg.fit(x.reshape(-1,1),y.reshape(-1,1))
      plt.scatter(x,y)
      plt.plot(x,body_reg.predict(x))
      plt.show()
  except Exception as e:
      print(e)
  </code></pre>
  <p>Can anyone explain why sklearn doesn't like my input????</p>