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.brownboost
import prediction, training
23 from daal.algorithms
import classifier
24 from daal.data_management
import (
25 FileDataSource, DataSourceIface, NumericTableIface, HomogenNumericTable, MergedNumericTable
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',
'brownboost_train.csv')
37 testDatasetFileName = os.path.join(DAAL_PREFIX,
'batch',
'brownboost_test.csv')
42 predictionResult =
None
43 testGroundTruth =
None
50 trainDataSource = FileDataSource(
52 DataSourceIface.notAllocateNumericTable,
53 DataSourceIface.doDictionaryFromContext
56 trainData = HomogenNumericTable(nFeatures, 0, NumericTableIface.doNotAllocate)
57 trainGroundTruth = HomogenNumericTable(1, 0, NumericTableIface.doNotAllocate)
58 mergedData = MergedNumericTable(trainData, trainGroundTruth)
61 trainDataSource.loadDataBlock(mergedData)
64 algorithm = training.Batch()
67 algorithm.input.set(classifier.training.data, trainData)
68 algorithm.input.set(classifier.training.labels, trainGroundTruth)
71 trainingResult = algorithm.compute()
75 global testGroundTruth, predictionResult
78 testDataSource = FileDataSource(
80 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()
107 predictionResult.get(classifier.prediction.prediction),
108 "Ground truth",
"Classification results",
109 "BrownBoost classification results (first 20 observations):", 20
112 if __name__ ==
"__main__":