[mlpack-git] [mlpack/mlpack] add overload that imputes every dimensions (#740)

Tham notifications at github.com
Wed Jul 27 13:31:54 EDT 2016


> +          DatasetMapper<MissingPolicy>,
> +          CustomImputation<double>> allImputer(allInfo, allCustomStrategy);
> +  // convert a or nan to 99 for all dimensions.
> +  allImputer.Impute(allInput, "a");
> +
> +  // Custom imputation result check
> +  BOOST_REQUIRE_CLOSE(allInput(0, 0), 99.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(0, 1), 5.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(0, 2), 8.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(1, 0), 2.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(1, 1), 6.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(1, 2), 9.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(2, 0), 3.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(2, 1), 99.0, 1e-5);
> +  BOOST_REQUIRE_CLOSE(allInput(2, 2), 10.0, 1e-5);
> +

Hi, Keon, I think we should do the test on rowMajor data too.

```
// Now, try impute() overload with all dimensions.
  arma::mat allInputColumnWise;
  MissingPolicy allPolicy({"a"});
  DatasetMapper<MissingPolicy> allInfo(allPolicy);
  BOOST_REQUIRE(data::Load("test_file.csv", allInputColumnWise, allInfo) == true);
  arma::mat allInputRowWise = allInputColumnWise;

  // convert missing vals to 99.
  CustomImputation<double> allCustomStrategy(99);
  Imputer<double,
          DatasetMapper<MissingPolicy>,
          CustomImputation<double>> allImputer(allInfo, allCustomStrategy);
  // convert a or nan to 99 for all dimensions.
  allImputer.Impute(allInputColumnWise, "a");
  allImputer.ColumnMajor() = true; //I add a new function to access ColumnMajor
  allImputer.Impute(allInputRowWise, "a");

  // Custom imputation result check
  auto requireClose = [](arma::mat const &input)
  {
      BOOST_REQUIRE_CLOSE(input(0, 0), 99.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(0, 1), 5.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(0, 2), 8.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(1, 0), 2.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(1, 1), 6.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(1, 2), 9.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(2, 0), 3.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(2, 1), 99.0, 1e-5);
      BOOST_REQUIRE_CLOSE(input(2, 2), 10.0, 1e-5);
  };

  requireClose(allInputColumnWise);  
  requireClose(allInputRowWise);

```

---
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/740/files/7e05bb9831e8dd58ee9e8d246dc0704a28afbe65#r72484785
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160727/5932d937/attachment-0001.html>


More information about the mlpack-git mailing list