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