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 BlockDescriptor, SOANumericTable, features, readOnly
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
33 if v == features.DAAL_CATEGORICAL:
34 return "DAAL_CATEGORICAL"
35 elif v == features.DAAL_ORDINAL:
37 elif v == features.DAAL_CONTINUOUS:
38 return "DAAL_CONTINUOUS"
40 return "[Unknown FeatureType]"
43 if __name__ ==
"__main__":
44 print(
"Structure of array (SOA) numeric table example\n")
51 dDataSOA = np.array([1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6, 2.8], dtype=np.float64)
52 fDataSOA = np.array([3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0], dtype=np.float32)
53 iDataSOA = np.array([-10, -20, -30, -40, -50, -60, -70, -80, -90, -100], dtype=np.int32)
54 cDataSOA = np.array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5], dtype=np.uint8)
56 dataTable = SOANumericTable(nFeatures, nObservations)
57 dataTable.setArray(cDataSOA, 0)
58 dataTable.setArray(fDataSOA, 1)
59 dataTable.setArray(dDataSOA, 2)
60 dataTable.setArray(iDataSOA, 3)
62 doubleBlock = BlockDescriptor()
63 dataTable.getBlockOfRows(firstReadRow, nRead, readOnly, doubleBlock)
65 doubleBlock.getArray(), nFeatures, doubleBlock.getNumberOfRows(), doubleBlock.getNumberOfColumns(),
66 "Print SOA data structures as double:"
68 dataTable.releaseBlockOfRows(doubleBlock)
71 intBlock = BlockDescriptor(ntype=np.intc)
72 dataTable.getBlockOfColumnValues(readFeatureIdx, firstReadRow, nObservations, readOnly, intBlock)
74 intBlock.getArray(), 1, intBlock.getNumberOfRows(), intBlock.getNumberOfColumns(),
75 "Print the first feature of SOA:", flt64=
False
77 dataTable.releaseBlockOfColumnValues(intBlock)
79 pDictionary = dataTable.getDictionary()
80 print(
"Number of features in table: " + str(pDictionary.getNumberOfFeatures()))
83 print(
"Default type in autogenerated dictionary:")
84 for i
in range(0, nFeatures):
85 featureType = pDictionary[i].featureType
86 print(
"Type of " + str(i) +
" feature: " + toString(featureType))
89 categoricalFeature = pDictionary[0]
90 categoricalFeature.featureType = features.DAAL_CATEGORICAL
92 print(
"Modified type in the dictionary:")
93 for i
in range(0, nFeatures):
94 featureType = pDictionary[i].featureType
95 print(
"Type of " + str(i) +
" feature: " + toString(featureType))