[mlpack-git] master: Rename to match other enums. (fcf3425)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Dec 23 11:41:38 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/de9cc4b05069e1fa4793d9355f2f595af5ff45d2...6070527af14296cd99739de6c62666cc5d2a2125
>---------------------------------------------------------------
commit fcf3425af38f57405c17e6c7fb59baa2f65a149a
Author: ryan <ryan at ratml.org>
Date: Wed Sep 9 10:31:53 2015 -0400
Rename to match other enums.
>---------------------------------------------------------------
fcf3425af38f57405c17e6c7fb59baa2f65a149a
src/mlpack/core/data/dataset_info.hpp | 18 ++++++++++++------
src/mlpack/core/data/dataset_info_impl.hpp | 6 +++---
src/mlpack/tests/load_save_test.cpp | 9 +++------
3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/mlpack/core/data/dataset_info.hpp b/src/mlpack/core/data/dataset_info.hpp
index 77aeb36..d71dfce 100644
--- a/src/mlpack/core/data/dataset_info.hpp
+++ b/src/mlpack/core/data/dataset_info.hpp
@@ -17,6 +17,18 @@ namespace mlpack {
namespace data {
/**
+ * The Datatype enum specifies the types of data mlpack algorithms can use. The
+ * vast majority of mlpack algorithms can only use numeric data (i.e.
+ * float/double/etc.), but some algorithms can use categorical data, specified
+ * via this Datatype enum and the DatasetInfo class.
+ */
+enum Datatype : bool /* bool is all the precision we need for two types */
+{
+ numeric = 0,
+ categorical = 1
+};
+
+/**
* Auxiliary information for a dataset, including mappings to/from strings and
* the datatype of each dimension. DatasetInfo objects are optionally produced
* by data::Load(), and store the type of each dimension (Datatype::NUMERIC or
@@ -26,12 +38,6 @@ namespace data {
class DatasetInfo
{
public:
- enum Datatype
- {
- NUMERIC = 0,
- CATEGORICAL = 1
- };
-
DatasetInfo();
/**
diff --git a/src/mlpack/core/data/dataset_info_impl.hpp b/src/mlpack/core/data/dataset_info_impl.hpp
index bd389cc..b32472b 100644
--- a/src/mlpack/core/data/dataset_info_impl.hpp
+++ b/src/mlpack/core/data/dataset_info_impl.hpp
@@ -59,10 +59,10 @@ inline const std::string& DatasetInfo::UnmapString(
}
// Get the type of a particular dimension.
-inline DatasetInfo::Datatype DatasetInfo::Type(const size_t dimension) const
+inline Datatype DatasetInfo::Type(const size_t dimension) const
{
- return (maps.count(dimension) == 0) ? Datatype::NUMERIC :
- Datatype::CATEGORICAL;
+ return (maps.count(dimension) == 0) ? Datatype::numeric :
+ Datatype::categorical;
}
inline size_t DatasetInfo::NumMappings(const size_t dimension)
diff --git a/src/mlpack/tests/load_save_test.cpp b/src/mlpack/tests/load_save_test.cpp
index f78b732..27121ff 100644
--- a/src/mlpack/tests/load_save_test.cpp
+++ b/src/mlpack/tests/load_save_test.cpp
@@ -820,8 +820,7 @@ BOOST_AUTO_TEST_CASE(DatasetInfoTest)
// Do all types default to numeric?
for (size_t i = 0; i < 100; ++i)
{
- BOOST_REQUIRE_EQUAL((DatasetInfo::Datatype) di.Type(i),
- DatasetInfo::Datatype::NUMERIC);
+ BOOST_REQUIRE_EQUAL((Datatype) di.Type(i), Datatype::numeric);
BOOST_REQUIRE_EQUAL(di.NumMappings(i), 0);
}
@@ -839,14 +838,12 @@ BOOST_AUTO_TEST_CASE(DatasetInfoTest)
{
if (i == 3)
{
- BOOST_REQUIRE_EQUAL((DatasetInfo::Datatype) di.Type(i),
- DatasetInfo::Datatype::CATEGORICAL);
+ BOOST_REQUIRE_EQUAL((Datatype) di.Type(i), Datatype::categorical);
BOOST_REQUIRE_EQUAL(di.NumMappings(i), 3);
}
else
{
- BOOST_REQUIRE_EQUAL((DatasetInfo::Datatype) di.Type(i),
- DatasetInfo::Datatype::NUMERIC);
+ BOOST_REQUIRE_EQUAL((Datatype) di.Type(i), Datatype::numeric);
BOOST_REQUIRE_EQUAL(di.NumMappings(i), 0);
}
}
More information about the mlpack-git
mailing list