48 from daal.algorithms
import low_order_moments
49 from daal.data_management
import FileDataSource, DataSourceIface
51 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
52 if utils_folder
not in sys.path:
53 sys.path.insert(0, utils_folder)
54 from utils
import printNumericTable
56 DAAL_PREFIX = os.path.join(
'..',
'data')
59 datasetFileName = os.path.join(DAAL_PREFIX,
'online',
'covcormoments_dense.csv')
63 def printResults(res):
65 printNumericTable(res.get(low_order_moments.minimum),
"Minimum:")
66 printNumericTable(res.get(low_order_moments.maximum),
"Maximum:")
67 printNumericTable(res.get(low_order_moments.sum),
"Sum:")
68 printNumericTable(res.get(low_order_moments.sumSquares),
"Sum of squares:")
69 printNumericTable(res.get(low_order_moments.sumSquaresCentered),
"Sum of squared difference from the means:")
70 printNumericTable(res.get(low_order_moments.mean),
"Mean:")
71 printNumericTable(res.get(low_order_moments.secondOrderRawMoment),
"Second order raw moment:")
72 printNumericTable(res.get(low_order_moments.variance),
"Variance:")
73 printNumericTable(res.get(low_order_moments.standardDeviation),
"Standard deviation:")
74 printNumericTable(res.get(low_order_moments.variation),
"Variation:")
76 if __name__ ==
"__main__":
79 dataSource = FileDataSource(
80 datasetFileName, DataSourceIface.doAllocateNumericTable,
81 DataSourceIface.doDictionaryFromContext
85 algorithm = low_order_moments.Online()
87 while(dataSource.loadDataBlock(nVectorsInBlock) == nVectorsInBlock):
89 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
95 res = algorithm.finalizeCompute()