<p dir="auto">I'm using IncrementalPCA.partial_fit within a loop over a large array that I read in from a file sequentially to avoid memory limitations. After 5 iterations, I'm getting an explained variance ratio of just the first component of 31.8... Each iteration of partial_fit uses 500 samples with 840 features. IncrementalPCA is initialized to keep 100 components.</p>
<p dir="auto">code snippet:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        Xarray = np.genfromtxt(f, skip_header=start_row, max_rows=increment, delimiter=',')
        print &quot;Xarray shape: {}&quot;.format(Xarray.shape)

        while (Xarray is not None):

            ipca.partial_fit(Xarray)
            print &quot;PCA after {} samples seen&quot;.format(ipca.n_samples_seen_)
            print ipca.explained_variance_ratio_
            start_row += increment
            print &quot;start_row: {}&quot;.format(start_row)
            Xarray = np.genfromtxt(f, skip_header=start_row, max_rows=increment, delimiter=',')
            print &quot;Xarray shape: {}&quot;.format(Xarray.shape)"><pre class="notranslate"><code class="notranslate">        Xarray = np.genfromtxt(f, skip_header=start_row, max_rows=increment, delimiter=',')
        print "Xarray shape: {}".format(Xarray.shape)

        while (Xarray is not None):

            ipca.partial_fit(Xarray)
            print "PCA after {} samples seen".format(ipca.n_samples_seen_)
            print ipca.explained_variance_ratio_
            start_row += increment
            print "start_row: {}".format(start_row)
            Xarray = np.genfromtxt(f, skip_header=start_row, max_rows=increment, delimiter=',')
            print "Xarray shape: {}".format(Xarray.shape)
</code></pre></div>
<p dir="auto">output snippet:</p>
<p dir="auto">PCA after 2500 samples seen<br>
[  3.18056975e+01   4.98029267e-01   4.43883664e-01   4.08451255e-01<br>
3.89128549e-01   3.77518999e-01   3.56542640e-01   3.33262109e-01<br>
3.14950109e-01   2.98874660e-01   2.85867538e-01   2.81010422e-01<br>
2.72842557e-01   2.63025294e-01   2.54989075e-01   2.50687686e-01<br>
2.48726216e-01   2.35796452e-01   2.30737988e-01   2.21640908e-01<br>
2.13462023e-01   2.01752219e-01   1.95959838e-01   1.95708886e-01<br>
1.87027547e-01   1.82996412e-01   1.79610949e-01   1.74964506e-01<br>
1.60011439e-01   1.49475301e-01   1.40894784e-01   1.35475019e-01<br>
1.25310298e-01   1.22854195e-01   1.13804103e-01   1.13238117e-01<br>
1.11017593e-01   1.07160756e-01   1.03961022e-01   9.42830621e-02<br>
8.58979109e-02   7.65082305e-02   6.75815877e-02   6.48157108e-02<br>
5.79329461e-02   5.49496091e-02   3.76775268e-02   2.08521555e-02<br>
1.96837250e-02   1.37371817e-02   7.19341856e-03   6.08796477e-03<br>
5.17738195e-03   4.85022397e-03   4.57451540e-03   3.69717201e-03<br>
3.61169834e-03   2.89407860e-03   2.09412930e-03   1.62549028e-03<br>
1.49595829e-03   1.30557971e-03   1.03945572e-03   9.26718009e-04<br>
8.26675398e-04   7.57518243e-04   7.17753386e-04   5.67656331e-04<br>
5.41295550e-04   4.92545563e-04   4.78711593e-04   4.42107099e-04<br>
3.65606069e-04   3.57073238e-04   2.96661647e-04   2.73361497e-04<br>
2.66919822e-04   2.45986959e-04   2.41616313e-04   2.34303943e-04<br>
2.25211473e-04   2.15443298e-04   2.10465870e-04   2.05961013e-04<br>
1.95109203e-04   1.85263196e-04   1.73445133e-04   1.69027180e-04<br>
1.56755129e-04   1.52948248e-04   1.51477907e-04   1.48012761e-04<br>
1.42888295e-04   1.40980522e-04   1.24088002e-04   1.14768643e-04<br>
4.43898504e-05   2.33152703e-05   2.06950098e-05   1.62836044e-05]<br>
start_row: 2500<br>
Xarray shape: (500, 840)</p>
<p dir="auto">FastICA uses print to tell a user about that the number of components is larger than the number of available features (<a href="https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/decomposition/fastica_.py#L296">https://github.com/scikit-learn/scikit-learn/blob/51a765a/sklearn/decomposition/fastica_.py#L296</a>). This makes it unnecessarily hard to catch the output and redirect it to a logger.</p>
<p dir="auto">I propose to use <code class="notranslate">warnings.warn</code>, as in <a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/kernel_approximation.py#L463">kernel approximation</a> or <a href="https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/discriminant_analysis.py#L690">qda</a>.</p>