title: Matrix Approximation and Predicting Timeseries in Python/R with SVD
body: <p>I have an excel file that is 126 rows and 5 columns full of numbers, I have to use that data and SVD methods to predict 5-10 more rows of data. I have implemented SVD in Python successfully using numpy:</p>
  
  <p>import numpy as np
  from numpy import genfromtxt</p>
  
  <pre><code>my_data = genfromtxt('data.csv', delimiter=',')
  
  U, s, V = np.linalg.svd(my_data)
  
  print ("U:")
  print (U)
  print ("\nSigma:")
  print (s)
  print ("\nVT:")
  print (V)
  </code></pre>
  
  <p>which outputs:</p>
  
  <pre><code>U:
  [[-0.03339497  0.10018171  0.01013636 ..., -0.10076323 -0.09740801
    -0.08901366]
   [-0.02881809  0.0992715  -0.01239945 ..., -0.02920558 -0.04133748
    -0.06100236]
   [-0.02501102  0.10637736 -0.0528663  ..., -0.0885227  -0.05408083
    -0.01678337]
   ..., 
   [-0.02418483  0.10993637  0.05200962 ...,  0.9734676  -0.01866914
    -0.00870467]
   [-0.02944344  0.10238372  0.02009676 ..., -0.01948701  0.98455034
    -0.00975614]
   [-0.03109401  0.0973963  -0.0279125  ..., -0.01072974 -0.0109425
     0.98929811]]
  
  Sigma:
  [ 252943.48015512   74965.29844851   15170.76769244    4357.38062076
      3934.63212778]
  
  VT:
  [[-0.16143572 -0.22105626 -0.93558846 -0.14545156 -0.16908786]
   [ 0.5073101   0.40240734 -0.34460639  0.45443181  0.50541365]
   [-0.11561044  0.87141558 -0.07426656 -0.26914744 -0.38641073]
   [ 0.63320943 -0.09361249  0.00794671 -0.75788695  0.12580436]
   [-0.54977724  0.14516905 -0.01849291 -0.35426346  0.74217676]]
  </code></pre>
  
  <p>But I am not sure how to use this data to preidct my values. I am using this link <a href="http://datascientistinsights.com/2013/02/17/single-value-decomposition-a-golfers-tutotial/" rel="nofollow">http://datascientistinsights.com/2013/02/17/single-value-decomposition-a-golfers-tutotial/</a> as a reference but that is in R. At the end they use R to predict values but they use this command in R:</p>
  
  <pre><code>approxGolf_1 &lt;- golfSVD$u[,1] %*% t(golfSVD$v[,1]) * golfSVD$d[1]
  </code></pre>
  
  <p>Here is the IdeOne link to the entire R code: <a href="http://ideone.com/Yj3y6j" rel="nofollow">http://ideone.com/Yj3y6j</a></p>
  
  <p>I'm not really familiar with R so can anyone let me know if there is a similar function in Python to the command above or explain what that command is doing exactly?</p>
  
  <p>Thanks.</p>