29 from daal.algorithms
import kernel_function
31 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
32 if utils_folder
not in sys.path:
33 sys.path.insert(0, utils_folder)
34 from utils
import printNumericTable, createSparseTable
36 data_dir = os.path.join(
'..',
'data',
'batch')
38 leftDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
39 rightDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
45 if __name__ ==
"__main__":
48 leftData = createSparseTable(leftDatasetFileName)
49 rightData = createSparseTable(rightDatasetFileName)
52 algorithm = kernel_function.linear.Batch(method=kernel_function.linear.fastCSR)
55 algorithm.parameter.k = k
56 algorithm.parameter.b = b
57 algorithm.parameter.computationMode = kernel_function.matrixMatrix
60 algorithm.input.set(kernel_function.X, leftData)
61 algorithm.input.set(kernel_function.Y, rightData)
65 result = algorithm.compute()
68 printNumericTable(result.get(kernel_function.values),
"Values")