31 from daal.algorithms
import kernel_function
33 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
34 if utils_folder
not in sys.path:
35 sys.path.insert(0, utils_folder)
36 from utils
import printNumericTable, createSparseTable
38 data_dir = os.path.join(
'..',
'data',
'batch')
40 leftDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
41 rightDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
47 if __name__ ==
"__main__":
50 leftData = createSparseTable(leftDatasetFileName)
51 rightData = createSparseTable(rightDatasetFileName)
54 algorithm = kernel_function.linear.Batch(method=kernel_function.linear.fastCSR)
57 algorithm.parameter.k = k
58 algorithm.parameter.b = b
59 algorithm.parameter.computationMode = kernel_function.matrixMatrix
62 algorithm.input.set(kernel_function.X, leftData)
63 algorithm.input.set(kernel_function.Y, rightData)
67 result = algorithm.compute()
70 printNumericTable(result.get(kernel_function.values),
"Values")