data-science

2024-01-30T17:59:10.871969Z

Is there a way in dtype-next to express this "shorter":

(def x (dt/->tensor [[1, 1], [1, 2], [2, 2], [2, 3]]))
(dtf/dot-product (first (dt/columns x)) (second (dt/columns x)))
Mainly to get rid of the duplication in calling columns ?

2024-02-18T20:15:01.761779Z

👍

Harold 2024-02-16T01:12:00.091629Z

The first way to express it "shorter" is by removing the unnecessary commas (all of them) 😄 /s Here are some other thoughts:

user> (require '[tech.v3.tensor :as dtt])
nil
user> (dtt/->tensor [[1 1] [1 2] [2 2] [2 3]])
#tech.v3.tensor<object>[4 2]
[[1 1]
 [1 2]
 [2 2]
 [2 3]]
user> (def x *1)
#'user/x
user> (require '[tech.v3.datatype.functional :as dfn])
nil
user> (dfn/dot-product (first (dtt/columns x))
                       (second (dtt/columns x)))
13.0
user> (let [[c0 c1] (dtt/columns x)] (dfn/dot-product c0 c1))
13.0
user> (apply dfn/dot-product (dtt/transpose x [1 0]))
13.0

Harold 2024-02-16T01:13:18.570889Z

@chris441 - vaguely relevant to your interests ^