(device: Device)
| 302 | |
| 303 | |
| 304 | def _basic_example(device: Device) -> Tuple[Any, Any, np.ndarray, np.ndarray]: |
| 305 | Df, _ = get_df_impl(device) |
| 306 | |
| 307 | enc = Df({"c": ["cdef", "abc", "def"]}, dtype="category") |
| 308 | codes = enc.c.cat.codes # 1, 0, 2 |
| 309 | assert_allclose(device, asarray(device, codes), np.array([1, 0, 2])) |
| 310 | encoded = np.array([codes.iloc[2], codes.iloc[1]]) # def, abc |
| 311 | np.testing.assert_allclose(encoded, [2, 0]) |
| 312 | |
| 313 | reenc = Df({"c": ["def", "abc"]}, dtype="category") # same as `encoded` |
| 314 | codes = reenc.c.cat.codes |
| 315 | assert_allclose(device, codes, np.array([1, 0])) |
| 316 | |
| 317 | y = np.array([0, 1, 2]) |
| 318 | |
| 319 | return enc, reenc, encoded, y |
| 320 | |
| 321 | |
| 322 | def run_basic_predict(DMatrixT: Type, device: Device, tdevice: Device) -> None: |
no test coverage detected