mlpack  2.0.1
dataset_info.hpp
Go to the documentation of this file.
1 
16 #ifndef __MLPACK_CORE_DATA_DATASET_INFO_HPP
17 #define __MLPACK_CORE_DATA_DATASET_INFO_HPP
18 
19 #include <mlpack/core.hpp>
20 #include <unordered_map>
21 #include <boost/bimap.hpp>
22 
23 namespace mlpack {
24 namespace data {
25 
32 enum Datatype : bool /* bool is all the precision we need for two types */
33 {
34  numeric = 0,
36 };
37 
46 {
47  public:
53  DatasetInfo(const size_t dimensionality = 0);
54 
64  size_t MapString(const std::string& string, const size_t dimension);
65 
66  const std::string& UnmapString(const size_t value, const size_t dimension);
67 
68  Datatype Type(const size_t dimension) const;
69  Datatype& Type(const size_t dimension);
70 
71  size_t NumMappings(const size_t dimension) const;
72 
73  size_t Dimensionality() const;
74 
75  template<typename Archive>
76  void Serialize(Archive& ar, const unsigned int /* version */)
77  {
78  ar & data::CreateNVP(types, "types");
79  ar & data::CreateNVP(maps, "maps");
80  }
81 
82  private:
83  std::vector<Datatype> types;
84 
85  // Map entries will only exist for dimensions that are categorical.
86  std::unordered_map<size_t, std::pair<boost::bimap<std::string, size_t>,
87  size_t>> maps;
88 
89 };
90 
91 } // namespace data
92 } // namespace mlpack
93 
94 #include "dataset_info_impl.hpp"
95 
96 #endif
std::unordered_map< size_t, std::pair< boost::bimap< std::string, size_t >, size_t > > maps
DatasetInfo(const size_t dimensionality=0)
Create the DatasetInfo object with the given dimensionality.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
Datatype
The Datatype enum specifies the types of data mlpack algorithms can use.
Auxiliary information for a dataset, including mappings to/from strings and the datatype of each dime...
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
size_t MapString(const std::string &string, const size_t dimension)
Given the string and the dimension to which it belongs, return its numeric mapping.
void Serialize(Archive &ar, const unsigned int)
const std::string & UnmapString(const size_t value, const size_t dimension)
Datatype Type(const size_t dimension) const
size_t Dimensionality() const
std::vector< Datatype > types
size_t NumMappings(const size_t dimension) const