>>> xgboost(np.array([[ 2.3571 , 52. , 6.00813008, 1.06775068, ... 907. , 2.45799458, 40.58 , -124.26]]),np.array([1.114]), ... np.array([[1.97840000e+00, 3.70000000e+01, 4.98858447e+00, 1.03881279e+00, ... 1.14300000e+03, 2.60958904e+00, 3.67800000e+01, -1.19780000e+
(
features: np.ndarray, target: np.ndarray, test_features: np.ndarray
)
| 18 | |
| 19 | |
| 20 | def xgboost( |
| 21 | features: np.ndarray, target: np.ndarray, test_features: np.ndarray |
| 22 | ) -> np.ndarray: |
| 23 | """ |
| 24 | >>> xgboost(np.array([[ 2.3571 , 52. , 6.00813008, 1.06775068, |
| 25 | ... 907. , 2.45799458, 40.58 , -124.26]]),np.array([1.114]), |
| 26 | ... np.array([[1.97840000e+00, 3.70000000e+01, 4.98858447e+00, 1.03881279e+00, |
| 27 | ... 1.14300000e+03, 2.60958904e+00, 3.67800000e+01, -1.19780000e+02]])) |
| 28 | array([[1.1139996]], dtype=float32) |
| 29 | """ |
| 30 | xgb = XGBRegressor( |
| 31 | verbosity=0, random_state=42, tree_method="exact", base_score=0.5 |
| 32 | ) |
| 33 | xgb.fit(features, target) |
| 34 | # Predict target for test data |
| 35 | predictions = xgb.predict(test_features) |
| 36 | predictions = predictions.reshape(len(predictions), 1) |
| 37 | return predictions |
| 38 | |
| 39 | |
| 40 | def main() -> None: |