Python* API Reference for Intel® Data Analytics Acceleration Library 2019 Update 4

cor_csr_online.py

1 # file: cor_csr_online.py
2 #===============================================================================
3 # Copyright 2014-2019 Intel Corporation.
4 #
5 # This software and the related documents are Intel copyrighted materials, and
6 # your use of them is governed by the express license under which they were
7 # provided to you (License). Unless the License provides otherwise, you may not
8 # use, modify, copy, publish, distribute, disclose or transmit this software or
9 # the related documents without Intel's prior written permission.
10 #
11 # This software and the related documents are provided as is, with no express
12 # or implied warranties, other than those that are expressly stated in the
13 # License.
14 #===============================================================================
15 
16 
17 
18 
19 import os
20 import sys
21 
22 from daal.algorithms import covariance
23 
24 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
25 if utils_folder not in sys.path:
26  sys.path.insert(0, utils_folder)
27 from utils import printNumericTable, createSparseTable
28 
29 DAAL_PREFIX = os.path.join('..', 'data')
30 
31 # Input data set parameters
32 nBlocks = 4
33 datasetFileNames = [
34  os.path.join(DAAL_PREFIX, 'online', 'covcormoments_csr_1.csv'),
35  os.path.join(DAAL_PREFIX, 'online', 'covcormoments_csr_2.csv'),
36  os.path.join(DAAL_PREFIX, 'online', 'covcormoments_csr_3.csv'),
37  os.path.join(DAAL_PREFIX, 'online', 'covcormoments_csr_4.csv'),
38 ]
39 
40 if __name__ == "__main__":
41 
42  # Create algorithm objects for correlation matrix computing in online mode using default method
43  algorithm = covariance.Online()
44 
45  # Set the parameter to choose the type of the output matrix
46  algorithm.parameter.outputMatrixType = covariance.correlationMatrix
47 
48  for i in range(nBlocks):
49  dataTable = createSparseTable(datasetFileNames[i])
50 
51  # Set input arguments of the algorithm
52  algorithm.input.set(covariance.data, dataTable)
53 
54  # Compute partial correlation estimates
55  algorithm.compute()
56 
57  # Finalize online result and get computed correlation
58  res = algorithm.finalizeCompute()
59 
60  printNumericTable(res.get(covariance.correlation), "Correlation matrix (upper left square 10*10) :", 10, 10)
61  printNumericTable(res.get(covariance.mean), "Mean vector:", 1, 10)

For more complete information about compiler optimizations, see our Optimization Notice.