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.adaboost
import prediction, training
23 from daal.algorithms
import classifier
24 from daal.data_management
import (
25 FileDataSource, DataSourceIface, HomogenNumericTable, MergedNumericTable, NumericTableIface
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 printNumericTables
33 DAAL_PREFIX = os.path.join(
'..',
'data')
36 trainDatasetFileName = os.path.join(DAAL_PREFIX,
'batch',
'adaboost_train.csv')
38 testDatasetFileName = os.path.join(DAAL_PREFIX,
'batch',
'adaboost_test.csv')
43 predictionResult =
None
44 testGroundTruth =
None
51 trainDataSource = FileDataSource(
52 trainDatasetFileName, DataSourceIface.notAllocateNumericTable,
53 DataSourceIface.doDictionaryFromContext
57 trainData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
58 trainGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
59 mergedData = MergedNumericTable(trainData, trainGroundTruth)
62 trainDataSource.loadDataBlock(mergedData)
65 algorithm = training.Batch()
68 algorithm.input.set(classifier.training.data, trainData)
69 algorithm.input.set(classifier.training.labels, trainGroundTruth)
72 trainingResult = algorithm.compute()
76 global predictionResult, testGroundTruth
79 testDataSource = FileDataSource(
80 testDatasetFileName, DataSourceIface.notAllocateNumericTable,
81 DataSourceIface.doDictionaryFromContext
85 testData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
86 testGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
87 mergedData = MergedNumericTable(testData, testGroundTruth)
90 testDataSource.loadDataBlock(mergedData)
93 algorithm = prediction.Batch()
96 algorithm.input.setTable(classifier.prediction.data, testData)
97 algorithm.input.setModel(classifier.prediction.model, trainingResult.get(classifier.training.model))
101 predictionResult = algorithm.compute()
105 testGroundTruth, predictionResult.get(classifier.prediction.prediction),
106 "Ground truth",
"Classification results",
107 "AdaBoost classification results (first 20 observations):", 20, flt64=
False
110 if __name__ ==
"__main__":