With logistic regression

The following example shows how to implement the multi-class classification with Shark-ML and the logistic regression algorithm. The following code snippet introduces a function declaration for this kind of task:

void LRClassification(const ClassificationDataset& train,                       const ClassificationDataset& test,                       unsigned int num_classes) {...}

The following code snippet shows how to configure an object for multi-class classification:

OneVersusOneClassifier<RealVector> ovo;unsigned int pairs = num_classes * (num_classes - 1) / 2;std::vector<LinearClassifier<RealVector> > lr(pairs);for (std::size_t n = 0, cls1 = 1; cls1 < num_classes; cls1++) {    using BinaryClassifierType =  OneVersusOneClassifier<RealVector>::binary_classifier_type; ...

Get Hands-On Machine Learning with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.