Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Jun 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/python-guide/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -113,5 +113,5 @@ def experiment(objective, label_type, data):
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)}")