torcharrow.functional.bucketize¶
- torcharrow.functional.bucketize(value_col: NumericalColumn, borders: Union[ListColumn, List[Union[int, float]]]) NumericalColumn ¶
對輸入特徵應用桶化。這是推薦領域中常見的操作,用於將密集特徵轉換為稀疏特徵。
- 參數:
value_col (定義密集特徵的數值欄位) –
borders (離散化稀疏特徵的邊界值) –
範例
>>> import torcharrow as ta >>> from torcharrow import functional >>> a = ta.column([1, 2, 3, 5, 8, 10, 11]) >>> functional.bucketize(a, [2, 5, 10]) 0 0 1 0 2 1 3 1 4 2 5 2 6 3 dtype: Int32(nullable=True), length: 7, null_count: 0