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.
24 from daal.data_management
import features, AOSNumericTable, BlockDescriptor, readOnly, readWrite
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 printArray
32 if __name__ ==
"__main__":
34 print(
"Array of structures (AOS) numeric table example\n")
36 points = np.array([(0.5, -1.3, 1, 100.1),
37 (2.5, -3.3, 2, 200.2),
38 (4.5, -5.3, 2, 350.3),
39 (6.5, -7.3, 0, 470.4),
40 (8.5, -9.3, 1, 270.5)],
41 dtype=[(
'x',
'f4'), (
'y',
'f4'), (
'categ',
'i4'), (
'value',
'f8')])
43 nObservations = len(points)
44 nFeatures = len(points[0])
48 dataTable = AOSNumericTable(points)
51 dict = dataTable.getDictionary()
54 dict[0].featureType = features.DAAL_CONTINUOUS
55 dict[1].featureType = features.DAAL_CONTINUOUS
56 dict[2].featureType = features.DAAL_CATEGORICAL
57 dict[3].featureType = features.DAAL_CONTINUOUS
60 dict[2].categoryNumber = 3
64 doubleBlock = BlockDescriptor()
65 dataTable.getBlockOfRows(firstReadRow, nObservations, readWrite, doubleBlock)
67 doubleBlock.getArray(), nFeatures, doubleBlock.getNumberOfRows(),
68 doubleBlock.getNumberOfColumns(),
"Print AOS data structures as double:"
70 dataTable.releaseBlockOfRows(doubleBlock)
75 intBlock = BlockDescriptor(ntype=np.intc)
76 dataTable.getBlockOfColumnValues(readFeatureIdx, firstReadRow, nObservations, readOnly, intBlock)
78 intBlock.getArray(), 1, intBlock.getNumberOfRows(), intBlock.getNumberOfColumns(),
79 "Print the third feature of AOS:", flt64=
False
81 dataTable.releaseBlockOfColumnValues(intBlock)