0

I'm using CUDF it's part of the rapids ML suite from Nvidia.

Using this suite how would I do a dot product between two DataFrame?

a = cudf.DataFrame([[0.1, 0.2, 0.3, 0.4], [0.1, 0.2, 0.3, 0.4]])
b = cudf.DataFrame([[0.1, 0.2], [0.1, 0.2]])
a.T.dot(b) # It doesn't work, cudf doesn't supprot .dot

e.g. how would I perform a dot product on the above Dataframes?

albert
  • 8,285
  • 3
  • 19
  • 32
MrJasonLi
  • 21
  • 3

1 Answers1

0

cuDF doesn't directly support this operation on a Series or DataFrame, but you can zero-copy convert to CuPy arrays using the .values notation, do this operation, and convert the result back to a DataFrame with from_gpu_matrix.

import cudf

a = cudf.DataFrame([[0.1, 0.2, 0.3, 0.4], [0.1, 0.2, 0.3, 0.4]])
b = cudf.DataFrame([[0.1, 0.2], [0.1, 0.2]])
res = cudf.DataFrame.from_gpu_matrix(
    a.values.T.dot(b.values)
)

print(res)
    0   1
0   0.02    0.04
1   0.04    0.08
2   0.06    0.12
3   0.08    0.16
Nick Becker
  • 4,059
  • 13
  • 19