47 from daal.algorithms
import low_order_moments
48 from daal.data_management
import FileDataSource, DataSourceIface
50 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
51 if utils_folder
not in sys.path:
52 sys.path.insert(0, utils_folder)
53 from utils
import printNumericTable
55 DAAL_PREFIX = os.path.join(
'..',
'data')
58 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_dense.csv')
61 def printResults(res):
62 printNumericTable(res.get(low_order_moments.minimum),
"Minimum:")
63 printNumericTable(res.get(low_order_moments.maximum),
"Maximum:")
64 printNumericTable(res.get(low_order_moments.sum),
"Sum:")
65 printNumericTable(res.get(low_order_moments.sumSquares),
"Sum of squares:")
66 printNumericTable(res.get(low_order_moments.sumSquaresCentered),
"Sum of squared difference from the means:")
67 printNumericTable(res.get(low_order_moments.mean),
"Mean:")
68 printNumericTable(res.get(low_order_moments.secondOrderRawMoment),
"Second order raw moment:")
69 printNumericTable(res.get(low_order_moments.variance),
"Variance:")
70 printNumericTable(res.get(low_order_moments.standardDeviation),
"Standard deviation:")
71 printNumericTable(res.get(low_order_moments.variation),
"Variation:")
73 if __name__ ==
"__main__":
76 dataSource = FileDataSource(
78 DataSourceIface.doAllocateNumericTable,
79 DataSourceIface.doDictionaryFromContext
83 dataSource.loadDataBlock()
86 algorithm = low_order_moments.Batch()
89 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
92 res = algorithm.compute()