<p>In <a href="https://github.com/mlpack/mlpack/pull/694#discussion_r69919289">src/mlpack/core/data/imputation_methods/median_imputation.hpp</a>:</p>
<pre style='color:#555'>&gt; +              const bool transpose = true)
&gt; +  {
&gt; +    //initiate output
&gt; +    output = input;
&gt; +
&gt; +    if (transpose)
&gt; +    {
&gt; +      arma::Mat&lt;T&gt; medianMat = arma::median(input, 1);
&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(dimension, i) = medianMat(dimension, 0);
&gt; +        }
&gt; +      }
</pre>
<p>This pattern seems to exist in all of the imputation strategies, so my comment here applies to all of them.  Here you are getting a single value out of each column, and each column is held contiguous in memory.  So each element you access is probably not in the same cache line, and as a result will probably be slower.  So if I were to call the imputer with every single dimension sequentially, it would be a lot slower than just taking one pass over the matrix and imputing each element as we went.  (It would also be slower in this case because we would be calculating the mean for every dimension every time we called the method.)</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#r69919289">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe/AJ4bFHtsHddLKPTtxoUEKCHrDjzB4jD1ks5qTRBVgaJpZM4I07W-">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFA4vQ81cgkxfltdy_iP8KO7dWnuhks5qTRBVgaJpZM4I07W-.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#r69919289"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>