[python-package] use f-strings for concatenation in examples/python-guide/logistic_regression.py (#4356)

* updated with f-string migration

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py
This commit is contained in:
Sagnik Roy 2021-06-09 03:50:24 +05:30 коммит произвёл GitHub
Родитель bab58d0e90
Коммит 8e5079efa1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -71,7 +71,7 @@ def experiment(objective, label_type, data):
"""
np.random.seed(0)
nrounds = 5
lgb_data = data['lgb_with_' + label_type + '_labels']
lgb_data = data[f"lgb_with_{label_type}_labels"]
params = {
'objective': objective,
'feature_fraction': 1,
@ -81,7 +81,7 @@ def experiment(objective, label_type, data):
time_zero = time.time()
gbm = lgb.train(params, lgb_data, num_boost_round=nrounds)
y_fitted = gbm.predict(data['X'])
y_true = data[label_type + '_labels']
y_true = data[f"{label_type}_labels"]
duration = time.time() - time_zero
return {
'time': duration,
@ -113,5 +113,5 @@ A = [experiment('binary', label_type='binary', data=DATA)['time']
for k in range(K)]
B = [experiment('xentropy', label_type='binary', data=DATA)['time']
for k in range(K)]
print('Best `binary` time: ' + str(min(A)))
print('Best `xentropy` time: ' + str(min(B)))
print(f"Best `binary` time: {min(A)}")
print(f"Best `xentropy` time: {min(B)}")