-
Book Overview & Buying
-
Table Of Contents
Hands-On Machine Learning with C++ - Second Edition
By :
There are a variety of file formats used for datasets, and not all of them might be supported by libraries. For using data from unsupported formats, we might need to write custom parsers. After we read values to regular C++ containers, we usually need to convert them into object types used in the ML framework we use. As an example, let’s consider the case of reading matrix data from files into C++ objects.
Using the Eigen library, we can wrap a C++ array into an Eigen::Matrix object with the Eigen::Map type. The wrapped object will behave as a standard Eigen matrix. We have to parametrize the Eigen::Map type with the type of matrix that has the required behavior. Also, when we create the Eigen::Map object, it takes as arguments a pointer to the C++ array and matrix dimensions, as illustrated in the following code snippet:
std::vector<double> values; ... auto x_data ...