Reading CSV files with the Dlib library

The Dlib library can load CSV files directly to its matrix type as the Shogun library does, but it does not require them to create a parser object. For this operation, we can use a simple C++ streaming operator and a standard std::ifstream object.

As a first step, we make the necessary includes, as follows:

include <Dlib/matrix.h>
using namespace Dlib;

Then, we define the matrix object and load data from the file, like this:

matrix<double> data;
std::ifstream file("iris_fix.csv");
file >> data;
std::cout << data << std::endl;

In the Dlib library, matrix objects are used for training machine learning algorithms directly, without the need to transform them into intermediate dataset types.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.30.62