55 from daal.algorithms
import kernel_function
57 utils_folder = os.path.realpath(os.path.abspath(os.path.dirname(os.path.dirname(__file__))))
58 if utils_folder
not in sys.path:
59 sys.path.insert(0, utils_folder)
60 from utils
import printNumericTable, createSparseTable
62 data_dir = os.path.join(
'..',
'data',
'batch')
64 leftDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
65 rightDatasetFileName = os.path.join(data_dir,
'kernel_function_csr.csv')
71 if __name__ ==
"__main__":
74 leftData = createSparseTable(leftDatasetFileName)
75 rightData = createSparseTable(rightDatasetFileName)
78 algorithm = kernel_function.linear.Batch(method=kernel_function.linear.fastCSR)
81 algorithm.parameter.k = k
82 algorithm.parameter.b = b
83 algorithm.parameter.computationMode = kernel_function.matrixMatrix
86 algorithm.input.set(kernel_function.X, leftData)
87 algorithm.input.set(kernel_function.Y, rightData)
91 result = algorithm.compute()
94 printNumericTable(result.get(kernel_function.values),
"Values")