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 dataFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_dense.csv')
62 def printResults(res):
63 printNumericTable(res.get(low_order_moments.minimum),
"Minimum:")
64 printNumericTable(res.get(low_order_moments.maximum),
"Maximum:")
65 printNumericTable(res.get(low_order_moments.sum),
"Sum:")
66 printNumericTable(res.get(low_order_moments.sumSquares),
"Sum of squares:")
67 printNumericTable(res.get(low_order_moments.sumSquaresCentered),
"Sum of squared difference from the means:")
68 printNumericTable(res.get(low_order_moments.mean),
"Mean:")
69 printNumericTable(res.get(low_order_moments.secondOrderRawMoment),
"Second order raw moment:")
70 printNumericTable(res.get(low_order_moments.variance),
"Variance:")
71 printNumericTable(res.get(low_order_moments.standardDeviation),
"Standard deviation:")
72 printNumericTable(res.get(low_order_moments.variation),
"Variation:")
74 if __name__ ==
"__main__":
77 dataSource = FileDataSource(
79 DataSourceIface.doAllocateNumericTable,
80 DataSourceIface.doDictionaryFromContext
84 dataSource.loadDataBlock()
87 algorithm = low_order_moments.Batch()
90 algorithm.input.set(low_order_moments.data, dataSource.getNumericTable())
93 res = algorithm.compute()