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 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_dense.csv')
36 def printResults(res):
37 printNumericTable(res.get(low_order_moments.minimum),
"Minimum:")
38 printNumericTable(res.get(low_order_moments.maximum),
"Maximum:")
39 printNumericTable(res.get(low_order_moments.sum),
"Sum:")
40 printNumericTable(res.get(low_order_moments.sumSquares),
"Sum of squares:")
41 printNumericTable(res.get(low_order_moments.sumSquaresCentered),
"Sum of squared difference from the means:")
42 printNumericTable(res.get(low_order_moments.mean),
"Mean:")
43 printNumericTable(res.get(low_order_moments.secondOrderRawMoment),
"Second order raw moment:")
44 printNumericTable(res.get(low_order_moments.variance),
"Variance:")
45 printNumericTable(res.get(low_order_moments.standardDeviation),
"Standard deviation:")
46 printNumericTable(res.get(low_order_moments.variation),
"Variation:")
48 if __name__ ==
"__main__":
51 dataSource = FileDataSource(
53 DataSourceIface.doAllocateNumericTable,
54 DataSourceIface.doDictionaryFromContext
58 dataSource.loadDataBlock()
61 algorithm = low_order_moments.Batch()
64 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
67 res = algorithm.compute()