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 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_dense.csv')
38 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(
55 DataSourceIface.doAllocateNumericTable,
56 DataSourceIface.doDictionaryFromContext
60 dataSource.loadDataBlock()
63 algorithm = low_order_moments.Batch()
66 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
69 res = algorithm.compute()