#include "daal.h"
#include "service.h"
using namespace std;
using namespace daal;
using namespace daal::algorithms;
const string datasetFileName = "../data/online/covcormoments_dense.csv";
const size_t nVectorsInBlock = 50;
void printResults(const low_order_moments::ResultPtr &res);
int main(int argc, char *argv[])
{
FileDataSource<CSVFeatureManager> dataSource(datasetFileName, DataSource::doAllocateNumericTable,
DataSource::doDictionaryFromContext);
low_order_moments::Online<> algorithm;
while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock)
{
algorithm.input.set(low_order_moments::data, dataSource.getNumericTable());
algorithm.compute();
}
algorithm.finalizeCompute();
low_order_moments::ResultPtr res = algorithm.getResult();
printResults(res);
return 0;
}
void printResults(const low_order_moments::ResultPtr &res)
{
printNumericTable(res->get(low_order_moments::minimum), "Minimum:");
printNumericTable(res->get(low_order_moments::maximum), "Maximum:");
printNumericTable(res->get(low_order_moments::sum), "Sum:");
printNumericTable(res->get(low_order_moments::sumSquares), "Sum of squares:");
printNumericTable(res->get(low_order_moments::sumSquaresCentered), "Sum of squared difference from the means:");
printNumericTable(res->get(low_order_moments::mean), "Mean:");
printNumericTable(res->get(low_order_moments::secondOrderRawMoment), "Second order raw moment:");
printNumericTable(res->get(low_order_moments::variance), "Variance:");
printNumericTable(res->get(low_order_moments::standardDeviation), "Standard deviation:");
printNumericTable(res->get(low_order_moments::variation), "Variation:");
}