Generate data for demo.
()
| 32 | |
| 33 | |
| 34 | def make_example_data() -> Tuple[pd.DataFrame, pd.Series, List[str]]: |
| 35 | """Generate data for demo.""" |
| 36 | n_samples = 2048 |
| 37 | rng = np.random.default_rng(1994) |
| 38 | |
| 39 | # We have three categorical features, while the rest are numerical. |
| 40 | categorical_features = ["brand_id", "retailer_id", "category_id"] |
| 41 | |
| 42 | df = pd.DataFrame( |
| 43 | np.random.randint(32, 96, size=(n_samples, 3)), |
| 44 | columns=categorical_features, |
| 45 | ) |
| 46 | |
| 47 | df["price"] = rng.integers(100, 200, size=(n_samples,)) |
| 48 | df["stock_status"] = rng.choice([True, False], n_samples) |
| 49 | df["on_sale"] = rng.choice([True, False], n_samples) |
| 50 | df["label"] = rng.normal(loc=0.0, scale=1.0, size=n_samples) |
| 51 | |
| 52 | X = df.drop(["label"], axis=1) |
| 53 | y = df["label"] |
| 54 | |
| 55 | return X, y, categorical_features |
| 56 | |
| 57 | |
| 58 | def native() -> None: |