<p>In <a href="https://github.com/mlpack/mlpack/pull/694#discussion_r69922436">src/mlpack/core/data/imputation_methods/listwise_deletion.hpp</a>:</p>
<pre style='color:#555'>&gt; +              const T&amp; mappedValue,
&gt; +              const size_t dimension,
&gt; +              const bool transpose = true)
&gt; +  {
&gt; +    // initiate output
&gt; +    output = input;
&gt; +    size_t count = 0;
&gt; +
&gt; +    if (transpose)
&gt; +    {
&gt; +      for (size_t i = 0; i &lt; input.n_cols; ++i)
&gt; +      {
&gt; +         if (input(dimension, i) == mappedValue ||
&gt; +             std::isnan(input(dimension, i)))
&gt; +         {
&gt; +           output.shed_col(i - count);
</pre>
<p>I think that here is might be faster to collect the list of columns that needs to be dropped, and then use non-contiguous matrix views to extract what you need to keep.  Something like this:</p>

<pre><code>std::vector&lt;arma::uword&gt; colsToKeep;
colsToKeep.push_back(0);
colsToKeep.push_back(2);
colsToKeep.push_back(3);

// Only keep columns 0, 2, and 3.
arma::mat output = input.cols(colsToKeep);
</code></pre>

<p>But before you commit that change, it is probably worth running some quick tests with <code>mlpack_preprocess_impute</code> to ensure that speeds things up.  I think you will see a lot of speedup with large matrices.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/mlpack/mlpack/pull/694/files/a8818316a04506530e2269a2e0a32ba2f6a1c83b#r69922436">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFNBtCRxIBB7lv1DwmzPy16eWmgwQks5qTRQRgaJpZM4I07W-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFKJ9gohqOJLs4_ZyxN6Bfa5Z2eljks5qTRQRgaJpZM4I07W-.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/694/files/a8818316a04506530e2269a2e0a32ba2f6a1c83b#r69922436"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>