Deprecation Notice: With the introduction of
daal4py, a package that supersedes PyDAAL, Intel is deprecating PyDAAL and will discontinue support starting with Intel® DAAL 2021 and Intel® Distribution for Python 2021. Until then Intel will continue to provide compatible pyDAAL
pip and
conda packages for newer releases of Intel DAAL and make it available in open source. However, Intel will not add the new features of Intel DAAL to pyDAAL. Intel recommends developers switch to and use daal4py.
Note: To find daal4py examples, refer to daal4py documentation
or browse github
repository.
22 from daal
import step1Local, step2Master
23 from daal.algorithms
import covariance
24 from daal.data_management
import FileDataSource, DataSourceIface
26 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
27 if utils_folder
not in sys.path:
28 sys.path.insert(0, utils_folder)
29 from utils
import printNumericTable
31 DAAL_PREFIX = os.path.join(
'..',
'data')
37 os.path.join(DAAL_PREFIX,
'distributed',
'covcormoments_dense_1.csv'),
38 os.path.join(DAAL_PREFIX,
'distributed',
'covcormoments_dense_2.csv'),
39 os.path.join(DAAL_PREFIX,
'distributed',
'covcormoments_dense_3.csv'),
40 os.path.join(DAAL_PREFIX,
'distributed',
'covcormoments_dense_4.csv')
43 partialResult = [0] * nBlocks
47 def computestep1Local(block):
51 dataSource = FileDataSource(
52 datasetFileNames[block], DataSourceIface.doAllocateNumericTable,
53 DataSourceIface.doDictionaryFromContext
57 dataSource.loadDataBlock()
60 algorithm = covariance.Distributed(step1Local)
63 algorithm.input.set(covariance.data, dataSource.getNumericTable())
66 partialResult[block] = algorithm.compute()
69 def computeOnMasterNode():
73 algorithm = covariance.Distributed(step2Master)
76 for i
in range(nBlocks):
77 algorithm.input.add(covariance.partialResults, partialResult[i])
80 algorithm.parameter.outputMatrixType = covariance.correlationMatrix
86 result = algorithm.finalizeCompute()
88 if __name__ ==
"__main__":
90 for i
in range(nBlocks):
95 printNumericTable(result.get(covariance.correlation),
"Correlation matrix:")
96 printNumericTable(result.get(covariance.mean),
"Mean vector:")