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

[docs] added new parameters aliases #1537

Merged
merged 4 commits into from
Jul 25, 2018
Merged

[docs] added new parameters aliases #1537

merged 4 commits into from
Jul 25, 2018

Conversation

StrikerRUS
Copy link
Collaborator

Added some new aliases for parameters and updated the codebase according to aliases treating mechanism at C++ side. See comments for details.

Copy link
Collaborator Author

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @Laurae2 for just letting you know about these updates in R

@@ -140,7 +140,7 @@ lgb.cv <- function(params = list(),
begin_iteration <- predictor$current_iter() + 1
}
# Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one
n_trees <- c("num_iterations", "num_iteration", "num_tree", "num_trees", "num_round", "num_rounds")
n_trees <- c("num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees", "num_round", "num_rounds", "num_boost_round", "n_estimators")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes in R

@@ -117,7 +117,7 @@ lgb.train <- function(params = list(),
begin_iteration <- predictor$current_iter() + 1
}
# Check for number of rounds passed as parameter - in case there are multiple ones, take only the first one
n_rounds <- c("num_iterations", "num_iteration", "num_tree", "num_trees", "num_round", "num_rounds")
n_rounds <- c("num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees", "num_round", "num_rounds", "num_boost_round", "n_estimators")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes in R

Copy link
Collaborator Author

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following aliases are taken from here https://xgboost.readthedocs.io/en/latest/parameter.html

// check = >=0
// desc = number of boosting iterations
// desc = **Note**: for Python/R-package, **this parameter is ignored**, use ``num_boost_round`` (Python) or ``nrounds`` (R) input arguments of ``train`` and ``cv`` methods instead
// desc = **Note**: internally, LightGBM constructs ``num_class * num_iterations`` trees for multi-class classification problems
int num_iterations = 100;

// alias = shrinkage_rate
// alias = shrinkage_rate, eta
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

// check = >0.0
// desc = shrinkage rate
// desc = in ``dart``, it also affects on normalization weights of dropped trees
double learning_rate = 0.1;

// default = 31
// alias = num_leaf
// alias = num_leaf, max_leaves, max_leaf
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

@@ -266,7 +266,7 @@ struct Config {
// desc = L1 regularization
double lambda_l1 = 0.0;

// alias = reg_lambda
// alias = reg_lambda, lambda
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

@@ -276,21 +276,22 @@ struct Config {
// desc = the minimal gain to perform split
double min_gain_to_split = 0.0;

// alias = rate_drop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

@@ -407,6 +410,7 @@ struct Config {
// desc = **Note**: can be used only in CLI version
std::string output_model = "LightGBM_model.txt";

// alias = save_period
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

@@ -419,7 +423,7 @@ struct Config {
// desc = **Note**: can be used only in CLI version
std::string input_model = "";

// alias = predict_result, prediction_result
// alias = predict_result, prediction_result, predict_name, prediction_name, pred_name, name_pred
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xgboost

Copy link
Collaborator Author

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbosity and verbose have equal priority.

@@ -660,12 +660,8 @@ def _lazy_init(self, data, label=None, reference=None,
warnings.warn('{0} keyword has been found in `params` and will be ignored. '
'Please use {0} argument of the Dataset constructor to pass this parameter.'.format(key))
self.predictor = predictor
if "verbosity" in params:
params.setdefault("verbose", params.pop("verbosity"))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now aliases are treated at C++ side

if silent:
params["verbose"] = 0
elif "verbose" not in params:
params["verbose"] = 1
Copy link
Collaborator Author

@StrikerRUS StrikerRUS Jul 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do this, since 1 is the default value at C++ side

Copy link
Collaborator Author

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved sklearn names to aliases. Now, for instance, n_jobs can be used in predict method

@@ -397,9 +397,6 @@ def fit(self, X, y,
self._fobj = None
evals_result = {}
params = self.get_params()
# sklearn interface has another naming convention
params.setdefault('seed', params.pop('random_state'))
params.setdefault('nthread', params.pop('n_jobs'))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move these names to aliases at C++ side

iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)

# Tests that `seed` is the same as `random_state`
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With adding this argument name to aliases at C++ side, this test becomes useless

@chivee chivee merged commit 00a125d into master Jul 25, 2018
@chivee chivee deleted the aliases branch July 25, 2018 02:13
@chivee chivee restored the aliases branch July 25, 2018 02:13
@StrikerRUS StrikerRUS deleted the aliases branch July 25, 2018 12:12
@lock lock bot locked as resolved and limited conversation to collaborators Mar 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants