@@ -17,15 +17,14 @@ def data_handling(data: dict) -> tuple:
17
17
return (data ["data" ], data ["target" ])
18
18
19
19
20
- def lgbm_regressor (
21
- features : np .ndarray , target : np .ndarray , test_features : np .ndarray
22
- ) -> np .ndarray :
20
+ def lgbm_regressor (features : np .ndarray , target : np .ndarray ,
21
+ test_features : np .ndarray ) -> np .ndarray :
23
22
"""
24
- >>> lgbm_regressor(np.array([[ 0.12, 0.02, 0.01, 0.25, 0.09]]), np.array([1]),
25
- ... np.array([[ 0.11, 0.03, 0.02, 0.28, 0.08]]))
23
+ >>> lgbm_regressor(np.array([[0.12, 0.02, 0.01, 0.25, 0.09]]),
24
+ ... np.array([1]), np.array([[ 0.11, 0.03, 0.02, 0.28, 0.08]]))
26
25
array([[0.98]], dtype=float32)
27
26
"""
28
- lgbm = LGBMRegressor (verbosity = 0 , random_state = 42 )
27
+ lgbm = LGBMRegressor (random_state = 42 )
29
28
lgbm .fit (features , target )
30
29
# Predict target for test data
31
30
predictions = lgbm .predict (test_features )
@@ -38,13 +37,9 @@ def main() -> None:
38
37
The URL for this algorithm:
39
38
https://lightgbm.readthedocs.io/en/latest/
40
39
Bank Marketing Dataset is used to demonstrate the algorithm.
41
-
42
- Expected error values:
43
- Mean Absolute Error: 0.2 (approx.)
44
- Mean Square Error: 0.15 (approx.)
45
40
"""
46
41
# Load Bank Marketing dataset
47
- bank_data = fetch_openml (name = " bank-marketing" , version = 1 , as_frame = False )
42
+ bank_data = fetch_openml (name = ' bank-marketing' , version = 1 , as_frame = False )
48
43
data , target = data_handling (bank_data )
49
44
x_train , x_test , y_train , y_test = train_test_split (
50
45
data , target , test_size = 0.25 , random_state = 1
0 commit comments