22 from daal.algorithms
import covariance
23 from daal.data_management
import FileDataSource, DataSourceIface
25 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
26 if utils_folder
not in sys.path:
27 sys.path.insert(0, utils_folder)
28 from utils
import printNumericTable
30 DAAL_PREFIX = os.path.join(
'..',
'data')
33 datasetFileName = os.path.join(DAAL_PREFIX,
'batch',
'covcormoments_dense.csv')
36 if __name__ ==
"__main__":
39 dataSource = FileDataSource(
40 datasetFileName, DataSourceIface.doAllocateNumericTable,
41 DataSourceIface.doDictionaryFromContext
45 algorithm = covariance.Online()
48 algorithm.parameter.outputMatrixType = covariance.correlationMatrix
50 while (dataSource.loadDataBlock(nObservations) == nObservations):
52 algorithm.input.set(covariance.data, dataSource.getNumericTable())
58 res = algorithm.finalizeCompute()
60 printNumericTable(res.get(covariance.correlation),
"Correlation matrix:")
61 printNumericTable(res.get(covariance.mean),
"Mean vector:")