title: my linear regression model wont fit needs 2D array
body: <p>So I have two 1D arrays which I need to plot and I want to also plot their linear regression model to know their trend, so I have the following code:</p>
  
  <pre><code>from brian2 import *
  %matplotlib inline
  from sklearn.linear_model import LinearRegression
  
  start_scope()
  
  reg = LinearRegression()
  reg.fit(rates, R)
  reg.coef_
  
  #rates and R were issued beforehand
  
  figure(figsize=(36,12))
  subplot(121)
  plot(rates,R,'o','b',reg,'r' )
  xlabel('Time (ms)')
  ylabel('V (mV)')
  title("M.I. - firing rate evolution")
  ylim((0,35))
  </code></pre>
  
  <p>and I then get this error:</p>
  
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-40-a93af061bea5&gt; in &lt;module&gt;
        1 reg = LinearRegression()
  ----&gt; 2 reg.fit(rates, R)
        3 reg.coef_
        4 
        5 figure(figsize=(36,12))
  
  ~/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/base.py in fit(self, X, y, sample_weight)
      456         n_jobs_ = self.n_jobs
      457         X, y = check_X_y(X, y, accept_sparse=['csr', 'csc', 'coo'],
  --&gt; 458                          y_numeric=True, multi_output=True)
      459 
      460         if sample_weight is not None and np.atleast_1d(sample_weight).ndim &gt; 1:
  
  ~/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
      745                     ensure_min_features=ensure_min_features,
      746                     warn_on_dtype=warn_on_dtype,
  --&gt; 747                     estimator=estimator)
      748     if multi_output:
      749         y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,
  
  ~/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
      545                     "Reshape your data either using array.reshape(-1, 1) if "
      546                     "your data has a single feature or array.reshape(1, -1) "
  --&gt; 547                     "if it contains a single sample.".format(array))
      548 
      549         # in the future np.flexible dtypes will be handled like object dtypes
  
  ValueError: Expected 2D array, got 1D array instead:
  array=[17.51666667 17.11666667 16.06666667 14.53333333 12.75        9.98333333].
  Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.
  </code></pre>
  
  <p>Can anyone help me understand?</p>