#include "daal.h"
#include "service.h"
using namespace std;
using namespace daal;
using namespace daal::algorithms;
using namespace daal::data_management;
string datasetFileName = "../data/batch/mse.csv";
const size_t nFeatures = 3;
float argumentValue[nFeatures + 1] = { -1, 0.1f, 0.15f, -0.5f};
int main(int argc, char *argv[])
{
FileDataSource<CSVFeatureManager> dataSource(datasetFileName,
DataSource::notAllocateNumericTable,
DataSource::doDictionaryFromContext);
NumericTablePtr data(new HomogenNumericTable<>(nFeatures, 0, NumericTable::doNotAllocate));
NumericTablePtr dependentVariables(new HomogenNumericTable<>(1, 0, NumericTable::doNotAllocate));
NumericTablePtr mergedData(new MergedNumericTable(data, dependentVariables));
dataSource.loadDataBlock(mergedData.get());
size_t nVectors = data->getNumberOfRows();
optimization_solver::mse::Batch<> mseObjectiveFunction(nVectors);
mseObjectiveFunction.input.set(optimization_solver::mse::data, data);
mseObjectiveFunction.input.set(optimization_solver::mse::dependentVariables, dependentVariables);
mseObjectiveFunction.input.set(optimization_solver::mse::argument,
NumericTablePtr(new HomogenNumericTable<>(argumentValue, 1, nFeatures + 1)));
mseObjectiveFunction.parameter().resultsToCompute =
optimization_solver::objective_function::gradient |
optimization_solver::objective_function::value |
optimization_solver::objective_function::hessian;
mseObjectiveFunction.compute();
printNumericTable(mseObjectiveFunction.getResult()->get(optimization_solver::objective_function::valueIdx), "Value");
printNumericTable(mseObjectiveFunction.getResult()->get(optimization_solver::objective_function::gradientIdx), "Gradient");
printNumericTable(mseObjectiveFunction.getResult()->get(optimization_solver::objective_function::hessianIdx), "Hessian");
return 0;
}