[mlpack-git] [mlpack/mlpack] DatasetMapper & Imputer (#694)

Tham notifications at github.com
Sun Jul 17 00:30:02 EDT 2016


> +
> +  BOOST_REQUIRE_CLOSE(output(0, 0), 3.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(0, 1), 99.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(0, 2), 2.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(0, 3), 0.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(1, 0), 5.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(1, 1), 6.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(1, 2), 0.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(1, 3), 6.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(2, 0), 9.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(2, 1), 8.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(2, 2), 4.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(output(2, 3), 8.0, 1e-5);
> +
> +  // overwrite to the input
> +  imputer.Impute(input, mappedValue, 0/*dimension*/, true);

I think we can reduce some duplicate codes

```
template<typename T>
void CheckEqual(arma::Mat<T> const &lhs, arma::Mat<T> const &rhs)
{
  BOOST_REQUIRE(lhs.n_rows == rhs.n_rows);
  BOOST_REQUIRE(lhs.n_cols == rhs.n_cols);
  for(size_t i = 0; i != lhs.n_elem; ++i)
  {
    BOOST_REQUIRE_CLOSE(lhs[i], rhs[i], 1e-5);
  }
}

//.......

// overwrite to the input
imputer.Impute(input, mappedValue, 0/*dimension*/, columnMajor);
CheckEqual(input, output);
```

---
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/e5d591e511ae449eae1523a80346357b93b968d1#r71076342
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160716/ac1fa0b4/attachment.html>


More information about the mlpack-git mailing list