title: How to do a regression starting from a list of list of elements
body: <p>I am trying to run a regression in python. I have a list of lists (part of a bigger list) that looks something like this:</p>
  
  <pre><code>[[1307622004, 0.0, 339.093, 130.132], 
  [10562004, 0.0, 206.818, 62.111], 
  [127882004, 0.0, 994.624, 360.497], 
  [63702004, 0.0, 89.653, 19.103], 
  [655902004, 0.0, 199.613, 83.296], 
  [76482004, 0.0, 1891.0, 508.0], 
  [16332004, 0.0, 160.344, 25.446], 
  [294352004, 0.0, 67.115, 22.646], 
  [615922004, 0.0, 134.501, 41.01], 
  [1212572004, 0.0, 232.616, 5.086], 
  [658992004, 0.0, 189.155, 7.906], 
  [61962004, 0.0, 806.7, 164.1], 
  [121712004, 0.0, 1147.532, 271.014], 
  [1250142004, 0.0, 29.556, -5.721], 
  [148082004, 0.0, 22.05, -17.655]]
  </code></pre>
  
  <p>It looks like this because each line is a row from a CSV file I am importing the data from. From this point on, please look at the elements in the list as columns of variables to better understand what I am trying to a regression on. For example, the first 4 lists from the list would look something like that turned into columns (I do not need the variables turned into columns I've done it for illustration purposes):</p>
  
  <pre><code>1307622004     0.0    339.093    130.132
  10562004       0.0    206.818    62.111
  127882004      0.0    994.624    360.497
  </code></pre>
  
  <p>To continue my example, I want the first column to be my dependent variable and all the other columns to be independent variables.
  I have tried using numpy to transform the list into an array and then apply sklearn regression. Below is a code snippet: </p>
  
  <p><strong>Important to note:</strong> The list_of_lists contains many elements similar to the list I have provided at the beginning of the question. </p>
  
  <pre><code>from sklearn import datasets ## imports datasets from scikit-learn
  from sklearn.linear_model import LinearRegression
  import numpy as np
  
  for item in list_of_lists:
      test_array = np.asarray(item)
      # print(test_array)
      X, Y = test_array[:, 0], test_array[:, 1]
      mdl = LinearRegression().fit(X, Y)
      scores = LinearRegression.score(X, Y)
      print('--------------------------')
  </code></pre>
  
  <p>The problem is that I get the following output:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>I am quite new to python and the usage of arrays, matrixes in python so I don't really understand what is happening. </p>