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.algorithms
import em_gmm
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 datasetFileName = os.path.join(DAAL_PREFIX,
'batch',
'em_gmm.csv')
36 if __name__ ==
"__main__":
39 dataSource = FileDataSource(
41 DataSourceIface.doAllocateNumericTable,
42 DataSourceIface.doDictionaryFromContext
44 nFeatures = dataSource.getNumberOfColumns()
47 dataSource.loadDataBlock()
51 initAlgorithm = em_gmm.init.Batch(nComponents)
54 initAlgorithm.input.set(em_gmm.init.data, dataSource.getNumericTable())
57 resultInit = initAlgorithm.compute()
60 algorithm = em_gmm.Batch(nComponents)
63 algorithm.input.setTable(em_gmm.data, dataSource.getNumericTable())
64 algorithm.input.setValues(em_gmm.inputValues, resultInit)
67 result = algorithm.compute()
70 printNumericTable(result.getResult(em_gmm.weights),
"Weights")
71 printNumericTable(result.getResult(em_gmm.means),
"Means")
72 for i
in range(nComponents):
73 printNumericTable(result.getCovariances(em_gmm.covariances, i),
"Covariance")