<div dir="ltr">So yes there is a difference between the two depending on the size of the matrix.<div><br></div><div>Following is an output from ipython:</div><div><br></div><div><b>With a matrix of shape (1000 * 500)</b><br></div><div><div>(batman3) tupui@Batman:Desktop $ ipython -i sk_pod.py</div><div>Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:44:09)</div><div>Type 'copyright', 'credits' or 'license' for more information</div><div>IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.</div><div><br></div><div>In [1]: %timeit pod._update(snapshot2.T)</div><div>491 ms ± 22.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</div><div><br></div><div>In [2]: %timeit ipca.partial_fit(snapshot2)</div><div>163 ms ± 1.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)</div></div><div><br></div><div><b>With a matrix of shape (1000 * 2000)</b></div><div><div>(batman3) tupui@Batman:Desktop $ ipython -i sk_pod.py</div><div>Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:44:09)</div><div>Type 'copyright', 'credits' or 'license' for more information</div><div>IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.</div><div><br></div><div>In [1]: %timeit pod._update(snapshot2.T)</div><div>4.84 s ± 220 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</div><div><br></div><div>In [2]: %timeit ipca.partial_fit(snapshot2)</div><div>5.85 s ± 77.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</div><div><br></div><div>In [3]:</div><div>Do you really want to exit ([y]/n)?</div><div><br></div><div><b>With a matrix of shape (1000 * 20 000)</b><br></div><div>(batman3) tupui@Batman:Desktop $ ipython -i sk_pod.py</div><div>Python 3.6.5 | packaged by conda-forge | (default, Apr  6 2018, 13:44:09)</div><div>Type 'copyright', 'credits' or 'license' for more information</div><div>IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.</div><div><br></div><div>In [1]: %timeit pod._update(snapshot2.T)</div><div>3.39 s ± 65.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)</div><div><br></div><div>In [2]: %timeit ipca.partial_fit(snapshot2)</div><div>33.1 s ± 17.7 s per loop (mean ± std. dev. of 7 runs, 1 loop each)</div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Conclusion is that, the method seems faster to add one sample if the number of feature is superior to the number of samples. </div><div class="gmail_extra">But if you want to add a bunch of sample, I found that sklearn seems a bit faster (38.75 s vs</div><div class="gmail_extra">34.51s to add 10 samples of shape 1000 * 20 000).</div><div class="gmail_extra">It is to be noted that in this last case, adding a single or 10 samples is taking the same time ~30s. So depending on how much sample are to be added, this can help.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Pamphile</div><div class="gmail_extra"><br></div><div class="gmail_extra">P.S. Following is the code I used (requires batman available though conda-forge):</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">import time</div><div class="gmail_extra">import numpy as np</div><div class="gmail_extra">from batman.pod import Pod</div><div class="gmail_extra">from sklearn.decomposition import IncrementalPCA</div><div class="gmail_extra"><br></div><div class="gmail_extra">n_samples, n_features = 1000, 20000</div><div class="gmail_extra"><br></div><div class="gmail_extra">snapshots = np.random.random_sample((n_<wbr>samples, n_features))</div><div class="gmail_extra">snapshot2 = np.random.random_sample((1, n_features))</div><div class="gmail_extra"><br></div><div class="gmail_extra">pod = Pod([np.zeros(n_features), np.ones(n_features)], None, np.inf, 1, 999)</div><div class="gmail_extra">pod._decompose(snapshots.T)</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">ipca = IncrementalPCA(999)</div><div class="gmail_extra">ipca.fit(snapshots)</div><div class="gmail_extra"><br></div><div class="gmail_extra">np.allclose(ipca.singular_<wbr>values_, pod.S)</div><div class="gmail_extra"><br></div><div class="gmail_extra">pod._update(snapshot2.T)</div><div class="gmail_extra">ipca.partial_fit(snapshot2)</div><div class="gmail_extra"><br></div><div class="gmail_extra">np.allclose(ipca.singular_<wbr>values_[:999], pod.S[:999])</div><div class="gmail_extra"><br></div><div class="gmail_extra">snapshot3 = np.random.random_sample((10, n_features))</div><div class="gmail_extra"><br></div><div class="gmail_extra">itime = time.time()</div><div class="gmail_extra">[pod._update(snap.T[:, None]) for snap in snapshot3]</div><div class="gmail_extra">print(time.time() - itime)</div><div class="gmail_extra"><br></div><div class="gmail_extra">itime = time.time()</div><div class="gmail_extra">ipca.partial_fit(snapshot3)</div><div class="gmail_extra">print(time.time() - itime)</div><div class="gmail_extra">np.allclose(ipca.singular_<wbr>values_[:999], pod.S[:999])</div><div><br></div></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">2018-07-03 11:06 GMT+02:00 Pamphile Roy <span dir="ltr"><<a href="mailto:roy.pamphile@gmail.com" target="_blank">roy.pamphile@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr">I have no idea about the comparison with <span style="color:rgb(0,0,0);white-space:pre-wrap">sklearn.decomposition.Inc<wbr>rementalPCA.</span><div><font color="#000000"><span style="white-space:pre-wrap">Was not aware of this but from the code it seems to be a different approach.<br></span></font><div><span style="color:rgb(0,0,0);white-space:pre-wrap">I will try to come with some numbers.</span></div></div><span class="gmail-m_3102888240581495704gmail-HOEnZb"><font color="#888888"><div><span style="color:rgb(0,0,0);white-space:pre-wrap"><br></span></div><div><span style="color:rgb(0,0,0);white-space:pre-wrap">Pamphile</span></div></font></span></div>
</blockquote></div><br></div></div>