• 文件 >
  • torcharrow.functional
捷徑

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

文字操作

add_tokens

將一系列標記/索引附加或前置到欄位。

推薦操作

bucketize

對輸入特徵應用桶化。

sigrid_hash

將雜湊函式套用至索引或索引列表。

firstx

返回輸入欄位開頭的前 x 個值

has_id_overlap

如果兩個輸入欄位重疊,則返回 1.0,否則返回 0.0

id_overlap_count

返回兩個 ID 列表之間的重疊數量

get_max_count

如果 input_ids 和 matching_ids 之間存在重疊的項目,則將重疊 ID 的最大實例數貢獻到最大計數。

get_jaccard_similarity

返回 input_ids 和 matching_ids 之間的 Jaccard 相似度。

get_cosine_similarity

返回由 input_id_scores 加權的 input_ids 定義的向量與由 matching_id_scores 加權的 matching_ids 定義的向量之間的餘弦值

get_score_sum

返回 matching_id_scores 中所有分數的總和,這些分數在 matching_ids 中具有對應的 ID,且該 ID 也在 input_ids 中。

get_score_min

從 matching_id_scores 中所有分數裡,找出其對應 ID 存在於 matching_ids 且同時也在 input_ids 中的最小值。

取得最高分數 (get_score_max)

從 matching_id_scores 中所有分數裡,找出其對應 ID 存在於 matching_ids 且同時也在 input_ids 中的最小值。

高階操作

縮放到 0 到 1 之間 (scale_to_0_1)

將欄位資料縮放到 [0, 1] 的範圍。

文件

取得 PyTorch 完整的開發者文件

檢視文件

教學

取得適用於初學者和進階開發者的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源