26 from daal.data_management
import features, AOSNumericTable, BlockDescriptor, readOnly, readWrite
28 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
29 if utils_folder
not in sys.path:
30 sys.path.insert(0, utils_folder)
31 from utils
import printArray
34 if __name__ ==
"__main__":
36 print(
"Array of structures (AOS) numeric table example\n")
38 points = np.array([(0.5, -1.3, 1, 100.1),
39 (2.5, -3.3, 2, 200.2),
40 (4.5, -5.3, 2, 350.3),
41 (6.5, -7.3, 0, 470.4),
42 (8.5, -9.3, 1, 270.5)],
43 dtype=[(
'x',
'f4'), (
'y',
'f4'), (
'categ',
'i4'), (
'value',
'f8')])
45 nObservations = len(points)
46 nFeatures = len(points[0])
50 dataTable = AOSNumericTable(points)
53 dict = dataTable.getDictionary()
56 dict[0].featureType = features.DAAL_CONTINUOUS
57 dict[1].featureType = features.DAAL_CONTINUOUS
58 dict[2].featureType = features.DAAL_CATEGORICAL
59 dict[3].featureType = features.DAAL_CONTINUOUS
62 dict[2].categoryNumber = 3
66 doubleBlock = BlockDescriptor()
67 dataTable.getBlockOfRows(firstReadRow, nObservations, readWrite, doubleBlock)
69 doubleBlock.getArray(), nFeatures, doubleBlock.getNumberOfRows(),
70 doubleBlock.getNumberOfColumns(),
"Print AOS data structures as double:"
72 dataTable.releaseBlockOfRows(doubleBlock)
77 intBlock = BlockDescriptor(ntype=np.intc)
78 dataTable.getBlockOfColumnValues(readFeatureIdx, firstReadRow, nObservations, readOnly, intBlock)
80 intBlock.getArray(), 1, intBlock.getNumberOfRows(), intBlock.getNumberOfColumns(),
81 "Print the third feature of AOS:", flt64=
False
83 dataTable.releaseBlockOfColumnValues(intBlock)