Skip to content

TST use global_random_seed in sklearn/linear_model/tests/test_logistic.py #31362

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

Open
wants to merge 55 commits into
base: main
Choose a base branch
from

Conversation

DeaMariaLeon
Copy link
Contributor

Reference Issues/PRs

Towards #22827

What does this implement/fix? Explain your changes.

Any other comments?

Copy link

github-actions bot commented May 13, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 9ab74c5. Link to the linter CI: here

@lorentzenchr
Copy link
Member

@DeaMariaLeon Please note that LogisticRegression makes use of random_state only when solver == ‘sag’, ‘saga’ or ‘liblinear’ (to shuffle the data).

@DeaMariaLeon
Copy link
Contributor Author

Thank you so much @lorentzenchr!

@@ -254,13 +253,16 @@ def test_elasticnet_l1_ratio_err_helpful(LR):
# TODO(1.8): remove whole test with deprecation of multi_class
@pytest.mark.filterwarnings("ignore:.*'multi_class' was deprecated.*:FutureWarning")
@pytest.mark.parametrize("solver", ["lbfgs", "newton-cg", "sag", "saga"])
def test_multinomial_binary(solver):
def test_multinomial_binary(global_random_seed, solver):
Copy link
Contributor Author

@DeaMariaLeon DeaMariaLeon May 20, 2025

Choose a reason for hiding this comment

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

Maybe this test doesn't need global_random_seed as it will be removed

Copy link
Contributor Author

@DeaMariaLeon DeaMariaLeon Jun 10, 2025

Choose a reason for hiding this comment

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

Remove test now (Guillaume's suggestion)

test_predict_2_classes
test_logistic_cv_mock_scorer
test_predict_iris
test_sparsify
test_write_parameters
test_consistency_path
test_liblinear_dual_random_state
test_logistic_cv
test_logistic_cv_multinomial_score
test_multinomial_logistic_regression_string_inputs
test_logistic_cv_sparse
test_logistic_regression_solvers
test_logistic_regression_solvers_multiclass
test_logistic_regression_solvers_multiclass_unpenalized
test_logistic_regression_class_weights
test_logistic_regression_multinomial
test_liblinear_decision_function_zero
test_liblinear_logregcv_sparse
test_saga_sparse
test_logreg_l1
test_logreg_l1_sparse_data
test_logistic_regression_cv_refit
test_logreg_predict_proba_multinomial
test_max_iter
test_warm_start
test_saga_vs_liblinear
test_dtype_match
test_warm_start_converge_LR
test_elastic_net_coeffs
test_elastic_net_l1_l2_equivalence
test_elastic_net_versus_sgd
test_penalty_none
test_scores_attribute_layout_elasticnet
test_multinomial_identifiability_on_iris
test_sample_weight_not_modified
test_liblinear_not_stuck
test_lr_cv_scores_differ_when_sample_weight_is_requested
test_passing_params_without_enabling_metadata_routing
@DeaMariaLeon
Copy link
Contributor Author

Still need to fix these:
test_LogisticRegression_elastic_net_objective
test_LogisticRegressionCV_GridSearchCV_elastic_net but feedback for the rest would be truly appreciated.

I removed some tests after conversation with Guillaume - but I hope that's what he meant.

@DeaMariaLeon DeaMariaLeon marked this pull request as ready for review July 15, 2025 12:42
test_logistic_cv_mock_scorer
test_predict_iris
test_sparsify
test_write_parameters
test_consistency_path
test_liblinear_dual_random_state
test_logistic_cv
test_logistic_cv_multinomial_score
test_multinomial_logistic_regression_string_inputs
test_logistic_cv_sparse
test_logistic_regression_solvers
test_logistic_regression_solvers_multiclass
test_logistic_regression_solvers_multiclass_unpenalized
test_logistic_regression_class_weights
test_logistic_regression_multinomial
test_liblinear_decision_function_zero
test_liblinear_logregcv_sparse
test_saga_sparse
test_logreg_l1
test_logreg_l1_sparse_data
test_logistic_regression_cv_refit
test_logreg_predict_proba_multinomial
test_max_iter
test_warm_start
test_saga_vs_liblinear
test_dtype_match
test_warm_start_converge_LR
test_elastic_net_coeffs
test_elastic_net_l1_l2_equivalence
test_elastic_net_versus_sgd
test_penalty_none
test_scores_attribute_layout_elasticnet
test_multinomial_identifiability_on_iris
test_sample_weight_not_modified
test_liblinear_not_stuck
test_lr_cv_scores_differ_when_sample_weight_is_requested
test_passing_params_without_enabling_metadata_routing
test_LogisticRegression_elastic_net_objective
test_LogisticRegressionCV_GridSearchCV_elastic_net
test_predict_2_classes
test_logistic_cv_mock_scorer
test_predict_iris
test_sparsify
test_write_parameters
test_consistency_path
test_liblinear_dual_random_state
test_logistic_cv
test_logistic_cv_multinomial_score
test_multinomial_logistic_regression_string_inputs
test_logistic_cv_sparse
test_logistic_regression_solvers
test_logistic_regression_solvers_multiclass
test_logistic_regression_solvers_multiclass_unpenalized
test_logistic_regression_class_weights
test_logistic_regression_multinomial
test_liblinear_decision_function_zero
test_liblinear_logregcv_sparse
test_saga_sparse
test_logreg_l1
test_logreg_l1_sparse_data
test_logistic_regression_cv_refit
test_logreg_predict_proba_multinomial
test_max_iter
test_warm_start
test_saga_vs_liblinear
test_dtype_match
test_warm_start_converge_LR
test_elastic_net_coeffs
test_elastic_net_l1_l2_equivalence
test_elastic_net_versus_sgd
test_penalty_none
test_scores_attribute_layout_elasticnet
test_multinomial_identifiability_on_iris
test_sample_weight_not_modified
test_liblinear_not_stuck
test_lr_cv_scores_differ_when_sample_weight_is_requested
test_passing_params_without_enabling_metadata_routing
test_LogisticRegression_elastic_net_objective
test_LogisticRegressionCV_GridSearchCV_elastic_net
test_predict_2_classes
test_logistic_cv_mock_scorer
test_predict_iris
test_sparsify
test_write_parameters
test_consistency_path
test_liblinear_dual_random_state
test_logistic_cv
test_logistic_cv_multinomial_score
test_multinomial_logistic_regression_string_inputs
test_logistic_cv_sparse
test_logistic_regression_solvers
test_logistic_regression_solvers_multiclass
test_logistic_regression_solvers_multiclass_unpenalized
test_logistic_regression_class_weights
test_logistic_regression_multinomial
test_liblinear_decision_function_zero
test_liblinear_logregcv_sparse
test_saga_sparse
test_logreg_l1
test_logreg_l1_sparse_data
test_logistic_regression_cv_refit
test_logreg_predict_proba_multinomial
test_max_iter
test_warm_start
test_saga_vs_liblinear
test_dtype_match
test_warm_start_converge_LR
test_elastic_net_coeffs
test_elastic_net_l1_l2_equivalence
test_elastic_net_versus_sgd
test_penalty_none
test_scores_attribute_layout_elasticnet
test_multinomial_identifiability_on_iris
test_sample_weight_not_modified
test_liblinear_not_stuck
test_lr_cv_scores_differ_when_sample_weight_is_requested
test_passing_params_without_enabling_metadata_routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants