title: How to print intercept and slope of a simple linear regression in Python with scikit-learn?
body: <p>I am trying to predict car prices (by machine learning) with a simple linear regression (only one independent variable). The variables are "highway miles per gallon"</p>
  
  <pre><code>0      27
  1      27
  2      26
  3      30
  4      22
         ..
  200    28
  201    25
  202    23
  203    27
  204    25
  Name: highway-mpg, Length: 205, dtype: int64
  </code></pre>
  
  <p>and "price":</p>
  
  <pre><code>0      13495.0
  1      16500.0
  2      16500.0
  3      13950.0
  4      17450.0
          ...   
  200    16845.0
  201    19045.0
  202    21485.0
  203    22470.0
  204    22625.0
  Name: price, Length: 205, dtype: float64
  </code></pre>
  
  <p>With the following code:</p>
  
  <pre><code>from sklearn.linear_model import LinearRegression
  
  x = df["highway-mpg"]
  y = df["price"]
  lm = LinearRegression()
  
  lm.fit([x],[y])
  Yhat = lm.predict([x])
  
  print(Yhat)
  print(lm.intercept_)
  print(lm.coef_)
  </code></pre>
  
  <p>However, the intercept and slope coefficient print commands give me the following output:</p>
  
  <pre><code>[[0. 0. 0. ... 0. 0. 0.]
   [0. 0. 0. ... 0. 0. 0.]
   [0. 0. 0. ... 0. 0. 0.]
   ...
   [0. 0. 0. ... 0. 0. 0.]
   [0. 0. 0. ... 0. 0. 0.]
   [0. 0. 0. ... 0. 0. 0.]]
  </code></pre>
  
  <p>Why doesn't it print the intercept and slope coefficient? The "Yhat" print command does print out the predicted values in an array properly, but somehow the other print commands do not print my desired output...</p>