[mlpack-git] [mlpack/mlpack] DatasetMapper & Imputer (#694)
Tham
notifications at github.com
Fri Jun 24 02:15:31 EDT 2016
> + double sum;
> + size_t elems = 0; // excluding nan or missing target
> +
> + using PairType = std::pair<size_t, size_t>;
> + // dimensions and indexes are saved as pairs inside this vector.
> + std::vector<PairType> targets;
> +
> + // calculate number of elements and sum of them excluding mapped value or
> + // nan. while doing that, remember where mappedValue or NaN exists.
> + if (transpose)
> + {
> + for (size_t i = 0; i < input.n_rows; ++i)
> + {
> + if (input(i, dimension) == mappedValue)
> + {
> + targets.push_back(std::make_pair(i, dimension));
Another approach(maybe you already know)--targets.emplace_back(i, dimension);
Different with push_back is emplace_back will construct the value directly,it may(or may not) provide better performance. Pick the one you like :)
---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/694/files/da4e40981c40e171858f41de4e85e08af2c7e48d..d8618ec909005b0453f0a3803ac1e6cc5e588f1f#r68357573
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160623/c9f6918c/attachment.html>
More information about the mlpack-git
mailing list