22 from daal.algorithms
import low_order_moments
23 from daal.data_management
import FileDataSource, DataSourceIface
25 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
26 if utils_folder
not in sys.path:
27 sys.path.insert(0, utils_folder)
28 from utils
import printNumericTable
30 DAAL_PREFIX = os.path.join(
'..',
'data')
33 datasetFileName = os.path.join(DAAL_PREFIX,
'online',
'covcormoments_dense.csv')
37 def printResults(res):
39 printNumericTable(res.get(low_order_moments.minimum),
"Minimum:")
40 printNumericTable(res.get(low_order_moments.maximum),
"Maximum:")
41 printNumericTable(res.get(low_order_moments.sum),
"Sum:")
42 printNumericTable(res.get(low_order_moments.sumSquares),
"Sum of squares:")
43 printNumericTable(res.get(low_order_moments.sumSquaresCentered),
"Sum of squared difference from the means:")
44 printNumericTable(res.get(low_order_moments.mean),
"Mean:")
45 printNumericTable(res.get(low_order_moments.secondOrderRawMoment),
"Second order raw moment:")
46 printNumericTable(res.get(low_order_moments.variance),
"Variance:")
47 printNumericTable(res.get(low_order_moments.standardDeviation),
"Standard deviation:")
48 printNumericTable(res.get(low_order_moments.variation),
"Variation:")
50 if __name__ ==
"__main__":
53 dataSource = FileDataSource(
54 datasetFileName, DataSourceIface.doAllocateNumericTable,
55 DataSourceIface.doDictionaryFromContext
59 algorithm = low_order_moments.Online()
61 while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock):
63 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
69 res = algorithm.finalizeCompute()