set black with 120 line length (#975)

* set black with 120 line length

* apply pre-commit

* apply black
This commit is contained in:
Jirka Borovec
2023-04-10 21:50:40 +02:00
committed by GitHub
parent ef5a17cd83
commit a701cd82f8
97 changed files with 809 additions and 2696 deletions

View File

@@ -7,9 +7,7 @@ from sklearn.metrics import mean_squared_error
data = fetch_california_housing(return_X_y=False, as_frame=True)
df, X, y = data.frame, data.data, data.target
df_train, _, X_train, X_test, _, y_test = train_test_split(
df, X, y, test_size=0.33, random_state=42
)
df_train, _, X_train, X_test, _, y_test = train_test_split(df, X, y, test_size=0.33, random_state=42)
csv_file_name = "test/housing.csv"
df_train.to_csv(csv_file_name, index=False)
# X, y = fetch_california_housing(return_X_y=True, as_frame=True)
@@ -24,9 +22,7 @@ def train_lgbm(config: dict) -> dict:
# train the model
# train_set = lightgbm.Dataset(X_train, y_train)
# LightGBM only accepts the csv with valid number format, if even these string columns are set to ignore.
train_set = lightgbm.Dataset(
csv_file_name, params={"label_column": "name:MedHouseVal", "header": True}
)
train_set = lightgbm.Dataset(csv_file_name, params={"label_column": "name:MedHouseVal", "header": True})
model = lightgbm.train(params, train_set)
# evaluate the model
pred = model.predict(X_test)
@@ -39,9 +35,7 @@ def test_tune_lgbm_csv():
# load a built-in search space from flaml
flaml_lgbm_search_space = LGBMEstimator.search_space(X_train.shape)
# specify the search space as a dict from hp name to domain; you can define your own search space same way
config_search_space = {
hp: space["domain"] for hp, space in flaml_lgbm_search_space.items()
}
config_search_space = {hp: space["domain"] for hp, space in flaml_lgbm_search_space.items()}
# give guidance about hp values corresponding to low training cost, i.e., {"n_estimators": 4, "num_leaves": 4}
low_cost_partial_config = {
hp: space["low_cost_init_value"]
@@ -50,11 +44,7 @@ def test_tune_lgbm_csv():
}
# initial points to evaluate
points_to_evaluate = [
{
hp: space["init_value"]
for hp, space in flaml_lgbm_search_space.items()
if "init_value" in space
}
{hp: space["init_value"] for hp, space in flaml_lgbm_search_space.items() if "init_value" in space}
]
# run the tuning, minimizing mse, with total time budget 3 seconds
analysis = tune.run(