torcharrow.functional¶
Velox 核心函式¶
Velox 核心函式 包含在 torcharrow.functional 中。
以下是 Velox 字串函式 lpad 的使用範例
>>> import torcharrow as ta
>>> from torcharrow import functional
>>> col = ta.column(["abc", "x", "yz"])
# Velox's lpad function: https://facebookincubator.github.io/velox/functions/string.html#lpad
>>> functional.lpad(col, 5, "123")
0 '12abc'
1 '1231x'
2 '123yz'
dtype: String(nullable=True), length: 3, null_count: 0, device: cpu
以下是 Velox 陣列函式 array_except 的另一個使用範例
>>> col1 = ta.column([[1, 2, 3], [1, 2, 3], [1, 2, 2], [1, 2, 2]])
>>> col2 = ta.column([[4, 5, 6], [1, 2], [1, 1, 2], [1, 3, 4]])
# Velox's array_except function: https://facebookincubator.github.io/velox/functions/array.html#array_except
>>> functional.array_except(col1, col2)
0 [1, 2, 3]
1 [3]
2 []
3 [2]
dtype: List(Int64(nullable=True), nullable=True), length: 4, null_count: 0
文字操作¶
將一系列標記/索引附加或前置到欄位。 |
推薦操作¶
對輸入特徵應用桶化。 |
|
將雜湊函式套用至索引或索引列表。 |
|
返回輸入欄位開頭的前 x 個值 |
|
如果兩個輸入欄位重疊,則返回 1.0,否則返回 0.0 |
|
返回兩個 ID 列表之間的重疊數量 |
|
如果 input_ids 和 matching_ids 之間存在重疊的項目,則將重疊 ID 的最大實例數貢獻到最大計數。 |
|
返回 input_ids 和 matching_ids 之間的 Jaccard 相似度。 |
|
返回由 input_id_scores 加權的 input_ids 定義的向量與由 matching_id_scores 加權的 matching_ids 定義的向量之間的餘弦值 |
|
返回 matching_id_scores 中所有分數的總和,這些分數在 matching_ids 中具有對應的 ID,且該 ID 也在 input_ids 中。 |
|
從 matching_id_scores 中所有分數裡,找出其對應 ID 存在於 matching_ids 且同時也在 input_ids 中的最小值。 |
|
從 matching_id_scores 中所有分數裡,找出其對應 ID 存在於 matching_ids 且同時也在 input_ids 中的最小值。 |
高階操作¶
將欄位資料縮放到 [0, 1] 的範圍。 |