()
| 105 | |
| 106 | |
| 107 | def generate_classification_model() -> None: |
| 108 | print("Classification") |
| 109 | X, y = make_classification( |
| 110 | n_samples=kRows, |
| 111 | n_features=kCols, |
| 112 | random_state=2025, |
| 113 | n_classes=kClasses, |
| 114 | n_informative=4, |
| 115 | n_redundant=0, |
| 116 | ) |
| 117 | w = np.random.default_rng(2025).uniform(size=X.shape[0]) |
| 118 | |
| 119 | data = xgboost.DMatrix(X, label=y, weight=w) |
| 120 | booster = xgboost.train( |
| 121 | { |
| 122 | "num_class": kClasses, |
| 123 | "tree_method": "hist", |
| 124 | "num_parallel_tree": kForests, |
| 125 | "max_depth": kMaxDepth, |
| 126 | }, |
| 127 | num_boost_round=kRounds, |
| 128 | dtrain=data, |
| 129 | ) |
| 130 | booster.save_model(booster_ubj("cls")) |
| 131 | booster.save_model(booster_json("cls")) |
| 132 | |
| 133 | cls = xgboost.XGBClassifier( |
| 134 | tree_method="hist", |
| 135 | num_parallel_tree=kForests, |
| 136 | max_depth=kMaxDepth, |
| 137 | n_estimators=kRounds, |
| 138 | ) |
| 139 | cls.fit(X, y, sample_weight=w) |
| 140 | cls.save_model(skl_ubj("cls")) |
| 141 | cls.save_model(skl_json("cls")) |
| 142 | |
| 143 | |
| 144 | def generate_ranking_model() -> None: |
no test coverage detected