Python* API Reference for Intel® Data Analytics Acceleration Library 2020 Update 1

abs_csr_batch.py

1 # file: abs_csr_batch.py
2 #===============================================================================
3 # Copyright 2014-2020 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #===============================================================================
17 
18 #
19 # ! Content:
20 # ! Python example of abs algorithm.
21 # !
22 # !*****************************************************************************
23 
24 # *
25 
26 
27 #
28 
29 import os
30 import sys
31 
32 import daal.algorithms.math.abs
33 from daal.algorithms import math
34 
35 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
36 if utils_folder not in sys.path:
37  sys.path.insert(0, utils_folder)
38 from utils import printNumericTable, createSparseTable
39 
40 
41 # Input data set parameters
42 datasetName = os.path.join('..', 'data', 'batch', 'covcormoments_csr.csv')
43 
44 if __name__ == "__main__":
45 
46  # Read datasetFileName from a file and create a numeric table to store input data
47  dataTable = createSparseTable(datasetName)
48 
49  # Create an algorithm
50  algorithm = math.abs.Batch(method=math.abs.fastCSR)
51 
52  # Set an input object for the algorithm
53  algorithm.input.set(math.abs.data, dataTable)
54 
55  # Compute Abs function
56  res = algorithm.compute()
57 
58  # Print the results of the algorithm
59  printNumericTable(res.get(math.abs.value), "Abs result (first 5 rows):", 5)

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